ghostscripts in python with watchdog
Peter Otten
__peter__ at web.de
Fri Feb 14 11:39:40 EST 2020
legaulph at gmail.com wrote:
> os.system("... {input_pdf} ...".format(..., input_pdf=input_pdf))
> I see it does not like spaces in the file name
Use subprocess.call(), not os.system(), then:
>>> filename = "hello world.txt"
>>> with open(filename, "w") as f: print("Hello, world!", file=f)
...
>>> import os, subprocess
Wrong, uses shell, and file name is not properly escaped:
>>> os.system("cat " + filename)
cat: hello: No such file or directory
cat: world.txt: No such file or directory
256
Right, does not use shell, no escaping needed:
>>> subprocess.call(["cat", filename])
Hello, world!
0
More information about the Python-list
mailing list