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)

沒有留言:

張貼留言

202501 Debian USB LAN Card Bridge

 202501 Debian USB LAN Card Bridge ChatGPT Question I have a machine running debian 12 with a LAN port using a cable to connect to my office...