2016年9月9日 星期五

Loop ping in Windows using Python 3

import subprocess

def ping(hostname):
  output = subprocess.Popen(["ping.exe", hostname, "-n", "1"], stdout = subprocess.PIPE).communicate()[0]
txt = output.decode('ascii')
return txt

for i in range(140, 200):
  hostname = "10.1.10." + str(i)
output = ping(hostname)
print(hostname, 'unreachable'
  not in output)

沒有留言:

張貼留言

2025 My Hardware Personal Computer Used

 2025 My Hardware Personal Computer Used Check Ubunut sudo dmidecode -t 2 sudo lsblk -o NAME,FSTYPE,LABEL,MOUNTPOINT,SIZE,MODEL 2025 Intel(R...