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

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c++ - CryptStringToBinary API behavior -