I am using a scientific software (called vasp) that works only in bash, and using Python to create a script that will make multiple runs for me. When I use subprocess.check_call to call the function normally, it works fine, but when i add the ‘| tee tee_output’ it doesn’t work.
subprocess.check_call('vasp') #this works
subprocess.check_call('vasp | tee tee_output') #this doesn't
I am a noobie to python and programming altogether.
Try this. It executes the command (passed as a string) via a shell, instead of executing the command directly. (It’s the equivalent of calling the shell itself with the
-cflag, i.e.Popen(['/bin/sh', '-c', args[0], args[1], ...])):But attend to the warning in the docs about this method.