SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top