1

I'm a newbie in programming in general, and with python in particular ...

I'm trying to write a python script, launched from a Linux Terminal, with a 'latex' file as an argument :

my_script.py file.tex.

I wish then my_script.py to open the file.tex in vim (in the Terminal), run another compiling script and then close, leaving 'file.tex' opened in vim and the compiling script running in background.

So, I tried :

myfile = "file.tex"
subprocess.call("vim "+ myfile)
subprocess.call("Latex_compiling_commande "+myfile)

but my_script.py is still waiting for vim to close before continuing, which is exaclty what subprocess.call is supposed to do, as explained in the : official python doc.

I tried :

subprocess.Popen(["vim", myfile])

I've got an 'input/ouput error'...

Thanks in advance.

2
  • You should probably just call vim non-interactively. See example here Commented Jan 16, 2015 at 17:48
  • Thanks for your comment; but I wish to use vim with all its special capabilities (latex-suite plugin, mappings, ...) Commented Jan 17, 2015 at 11:02

1 Answer 1

1

Try with:

import os
os.system("command")

For subprocess see this link

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks invictus for your answer. 'os.system("commad")' does the same : vim open 'file.tex'; I can edit the file, save it, do whatever I want; it's only after closing vim that my_script.py continues with the compiler command.
Thanks for the link as well; I have already checked it, but I think (as far as I understood) my question is a bit different : what 'file.tex' contains does not interact in any way with 'my_script.py'
What I really do not understand, is that : os.system("Latex_compiling_command "+ myfile) followed by os.system("vim "+myfile) works fine ... (my_script.py only ends when closing vim). Is there really any way to launch vim, then the Latex compiling command and then having my_script.py to close (leaving file.tex opened in vim in the Terminal) ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.