I've this shell command:
cat input | python 1.py > outfile
input
is a text file with values
3
1
4
5
and 1.py
is:
t = int(raw_input())
while t:
n = int(raw_input())
print n
t -= 1
It runs perfectly when I enter it in the terminal.
However, when I run this from Python using this code:
from subprocess import call
script = "cat input | python 1.py > outfile".split()
call(script)
I get:
3
1
4
5
cat: |: No such file or directory
cat: python: No such file or directory
t = int(raw_input())
while t:
n = int(raw_input())
print n
t -= 1
cat: >: No such file or directory
cat: outfile: No such file or directory
cat: |: No such file or directory
cat: python: No such file or directory
cat: >: No such file or directory
cat: outfile: No such file or directory
How do I get it right?