python - system calling with arguments and pipe -


i have text in variable called mytext, , want run command this:

mytext = "this text"     call("echo" + mytext + " | mail username -s subj") 

it means want echo text in mytext , pass mail command thru pipe. right way ?

you should have os command such popen allows create pipe make processes communicate between each other. check out page

from subprocess import popen, pipe p1 = popen(['echo', mytext], stdout=pipe) p2 = popen('mail', stdin=p1.stdout) 

this should work.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -