Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #!/usr/bin/python3.6
  2.  
  3.  
  4.  
  5. import subprocess as sp
  6.  
  7. def ipcheck():
  8. with open ('ip.txt', 'r') as ips:
  9. for ip in ips:
  10. status,result = sp.getstatusoutput("ping -c1 -w2 " + str(ip))
  11. if status == 0:
  12. print(str(ip.strip('\n')) + " is UP !")
  13. with open('wrokingip.txt', 'a') as data:
  14. ipas = ip.strip('\n')
  15. print(ipas)
  16. data.write(ipas+'\n')
  17. else:
  18. print(str(ip.strip('\n')) + " is DOWN !")
  19.  
  20. #pop=['10.159.45.79', '8.8.8.8']
  21. ipcheck()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement