how to pass "echo t | " input to subprocess.check_output() method

dachakku at gmail.com dachakku at gmail.com
Wed Nov 28 13:38:35 CET 2012


On Monday, 26 November 2012 21:10:02 UTC+5:30, Miki Tebeka  wrote:
> > But i dont know how to pass the "echo t | " in subprocess.check_output while calling a process.
> 
> You need to create two subprocess and connect the stdout of the first to the stdin of the 2'nd.
> 
> 
> 
> See http://pythonwise.blogspot.com/2008/08/pipe.html for a possible solution.

Hi Miki,
Thanks.. Creating two subprocesses worked for me. I did the code as below,

p = subprocess.Popen("echo t |", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
p1 = subprocess.Popen(["svn.exe", "list", "Https://127.0.0.1:443/svn/Repos"], shell=True, stdin=p.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
output = p1[0]

Thanks again... :)



More information about the Python-list mailing list