
Never call the latter if the process is not the lead process of a process group that’s attached to the current console session the results can be buggy in ways that break the entire console session due to bad design in the session host (i.e. If a process group is in the current console session, and only if it’s in the current console session, you can kill it via p.send_signal(signal.CTRL_BREAK_EVENT). If you also want a new console session, add the flag subprocess.CREATE_NEW_CONSOLE, but generally I don’t recommend that. In Python, the effect of the /B option is equivalent to calling subprocess.Popen with creationflags=subprocess.CREATE_NEW_PROCESS_GROUP. The start command doesn’t wait unless /W is used, e.g. If the /B option is used, then it creates a new process group in the current session. a complex pipeline).īy default, CMD’s internal start command executes the command line in a new console session and a new console process group that ignores Ctrl+C. On Windows it’s generally wrong because subprocess.list2cmdline() only supports argument quoting and escaping that matches WinAPI CommandLineToArgvW(), but the CMD shell uses different rules, and in general multiple rule sets may have to be supported (e.g. On POSIX using an argument list with shell=True is generally wrong because the arguments are passed as parameters to the shell. Generally you should use a command-line string with shell=True. In the end I want to run the script in the following way: python3 script.py H2_0_1.n(, shell=True) Output_file = xyzfile.split(".") + ".out"Īnd is created within the script via templating. The input file is derived from the *xyz file via xyzfile = str(sys.argv) The script reads and splits the filename by the point and creates an input file name H2.inp and the output should be written into the file H2.out. How do I "emulate" the command given at the top with the subprocess module?

I tried that with n(, stdout=output_file)īut so far it did not work. At the end the script should start the calculation in a way that I could log out of the server without stopping orca. Now I wanted to use a python script (with some templating) to write the input file automatically. So it would look like this: import subprocess n('python', 'myscript.py') It's also possible to write Python code directly to the function instead of passing a. Normally you start your quantum chemical programm (in my case it's called orca) with your input file (*.inp) on a remote server as a background process and pipe the output into an outputfile (*.out) via nohup orca H2.inp >& H2.out &

I want to automate some quantum chemical calculations and ran into a small problem. I'm looking for a solution for a probably quite easy problem.
