Hi all,
I am working on moving a small Python script from Windows to Linux and am running into a problem with one section of the code. Here is the snippet that is giving me problems.
Code:
for x in Dict1.keys():
return_code = subprocess.call(["/bin/ping -q -c 3",Dict1[x]])
if return_code == 0:
f.write(str(roomNo[i]) + ": \t " + str(Dict1[x]) + "\t Pass \n")
i = i + 1
num_pass = num_pass + 1
elif return_code == 1:
f.write(str(roomNo[i]) + ": \t " + str(Dict1[x]) + "\t Fail \n")
i = i + 1
num_fail = num_fail + 1
else:
pass
This code, modified accordingly, runs just fine under windows. Under Linux, it has a problem with the argument to the subprocess call. Here is the traceback:
Code:
Traceback (most recent call last):
File "./IPinger_Dev.py", line 323, in ?
main()
File "./IPinger_Dev.py", line 304, in main
testIP()
File "./IPinger_Dev.py", line 129, in testIP
return_code = subprocess.call(["/bin/ping -q -c 3",Dict1[x]])
File "/usr/lib/python2.4/subprocess.py", line 412, in call
return Popen(*args, **kwargs).wait()
File "/usr/lib/python2.4/subprocess.py", line 542, in __init__
errread, errwrite)
File "/usr/lib/python2.4/subprocess.py", line 975, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Thanks in advance
dmsynck