python - How do I get the log file a program creates when running it with subprocess.call()? -
i work gaussian, program molecular geometry optimization, among other applications. gaussian can take days end single optimization decided make program on python send me e-mail when finishes running. e-mail sending figured out. problem gaussian automatically generates log file , chk file, contains actual results of process , using subprocess.call(['command'], shell=false) both files not generated.
i tried solve problem os.system(command), gives me .log file , .chk file, e-mail sent without waiting optimization completion.
another important thing, have run entire process in background, because said @ beginning might take days on , can't leave terminal open long.
by using
subprocess.call(['command'], shell=false)both files not generated.
your comment suggests trying run subprocess.call(['g09 input.com &'], shell=false) wrong.
your code should raise filenotfounderror. if don't see it; means stderr hidden. should fix (make sure can see output of sys.stderr.write('stderr\n')). default, stderr not hidden i.e., way start parent script broken. able disconnect session, try:
$ nohup python /path/to/your_script.py &>your_script.log & or use screen, tmux.
shell=false (btw, default—no need pass explicitly) should hint call() function not expect shell command. , indeed, subprocess.call() accepts executable , parameters list instead—it not run shell:
subprocess.check_call(['g09', 'input.com', 'arg 2', 'etc']) note: check_call() raises exception if g09 returns non-zero exit code (it indicates error usually).
Comments
Post a Comment