[Tutor] Having a return when subprocess.Popen finishes

Paul VanGundy pvangundy at rez1.com
Thu Jul 8 15:04:54 CEST 2010

Hi All,

I'm trying to get data from subprocess.Popen. To be specific, I am
trying to read a ping echo and take the output and assign it to a
variable like below:

ping = subprocess.Popen("ping -c 5 %s" % (server),
stdout=subprocess.PIPE, shell=True)

However, when I run the command the output that gets assigned to my ping
variable is something along the lines of '<subprocess.Popen object at
0x9524bec>' and am not returned to >>> prompt. I know that is the proper
output but I need to be able to capture the ping replies and assign
those to a variable. I tried adding a \r and \n at the end of my cmd.
Any help would be greatly appreciated. I'm open to improvements,
different ways of doing it and corrections. :) If more info is needed
let me know. Thanks.


More information about the Tutor mailing list