I have the following code in python:
import subprocess
var = subprocess.Popen(["pdflatex","file.tex"])
Where var is a throw away variable because I don't care about the return variable. It does what I want (generates a pdf file from the latex file file.tex), but then waits for user input. These are the last lines of the program and I just want it to end without waiting for input. How can I do this?
Redirect stdin to devnull, to avoid a subprocess to pause waiting for user input:
import os
from subprocess import Popen
try:
from subprocess import DEVNULL # Python 3
except ImportError:
DEVNULL = open(os.devnull, 'r+b', 0)
Popen(['pdflatex', 'file.tex'], stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL)
I assume that you don't care about stdout/stderr also.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With