I have a related question to this one. The command that I'd like to execute is this one:
program test.in > test.out
where program
takes as input test.in
and outputs test.out
. In python, I do
import subprocess
subprocess.Popen([program] + ['test.in > test.out'])
yet I get the error
Cannot open file 'test.in > test.out' for reading.
I've also tried
subprocess.Popen([program] + 'test.in > test.out'.split())
yet this results in the error
Cannot open file `>` for reading.
How do I need to modify my script without using shell=True
, which would pose a security threat? Thanks.