would like to read and parse certain fields from multiple lines ( say lines 5 and 9 and the first and sixth fields respectively)
from the variable of the file the command output created
tried this code below but having problems parsing out_ping
from the variable of the file the command output created
tried this code below but having problems parsing out_ping
Code:
ip_array = ('192.168.1.1', '192.168.1.1', '124.128.x.x')
for i in ip_array:
out_ping = os.popen('ping' + ' ' + i, 'r+').read()
#sys.stdout.flush()
print out_ping
out_text = ('out_ping',5,9, 'r')
for line in out_text:
z = line.split()
if line 5 z[0] == "Reply" and line 9 z[6] < 80ms:
#sys.stdout.writelines(z[2] + reachable + "\n")
print z[2] + reachable + "\n"
else
print "congested"
Comment