when I run program below I am getting an index error on line 18
chk2 = .......
indexerror : list index out of range
Any help appreciated
Thx
chk2 = .......
indexerror : list index out of range
Any help appreciated
Thx
Code:
import os
import string
import sys
import linecache
ping_results = []
ip_array = ('192.168.1.43', '192.168.1.1', '127.0.0.1')
for ip in ip_array:
f = os.popen('ping %s' % (ip)).read()
out_ping = [item.strip() for item in f.splitlines(True)
if item.strip()]
#f.close()
ping_results.append(out_ping)
for result in ping_results:
chk1 = result[4]
chk2 = int(''.join([s for s in result[8].split() [-1]
if s.isdigit()]))
if chk1.startswith("Reply") and chk2 < 80:
print chk1
print result[8]
Comment