I want to create a subprocess with popen.
The special demand is to use shell direction in the command.
args = [
'/bin/cat',
'<',
'textfile',
]
process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env={'LANG':'de_DE@euro'})
processpid = process.pid
output = process.communicate()
I do not want to use the shell=True option, therefore here my question to you, how to implent it.
Regards
Stefan
Impossible unless the program you’re calling implements redirection itself (which
catdoesn’t). To use shell features, you have to passshell=Trueor invoke a shell explicitly.OTOH, if you just want to read from
textfile, you could pass it as the subprocess’sstdin: