I tried to use Python to call the command line to execute some files. However, when there is a command line containing both echo
and |
, the subprocess.call
seems not working very well. Like
when I run:
echo "perp -t ../data/ReviewTest.text" | ./eva -b ../data/6.binlm
I will get what I want. However, when I try this:
import subprocess
e=["echo","\"perp", "-t", "../data/R.text\"", "|", "./eva", "-b", "../data/6.binlm"]
subprocess(e)
I will get everything except echo showed in command line like:
".prep -t ..data/ReviewTest.text" | ./eva -b ../data/6.binlm
It seems that in subprocess.call()
, when there is an echo
, everything after it will just be thrown out onto the command line.
I hope there is some solution for me to use subprocess
when a command contains both echo
and |
.