I am trying to run a batch command using the subprocess module but it just isn't working. Here is my code:
import subprocess
subprocess.Popen('for /l %i in (5,1,255) do start /B ping -w 1 -n 1 192.168.0.%i | find /i "Reply"', stdout=subprocess.PIPE)
while True:
line = p.stdout.readline()
if not line:
print 'DONE PING'
break
print line
But every time I run this code I get "WindowsError: [Error 2] The system cannot find the file specified".
How do I run this batch command using the subprocess module?