It looks like you're trying to get the stdout from the process by printing the ping
variable in your example. That is incorrect usage of subprocess.Popen
objects. In order to correctly use subprocess.Popen
this is what you would write:
ping_process = subprocess.Popen(['ping', '-c', '1', ip], stdout=subprocess.PIPE)
# This will block until ping exits
stdout = ping_process.stdout.read()
print stdout
I also changed the arguments you used for ping because -n
is an invalid argument on my machines implementation.