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)

沒有留言:

張貼留言

2023 Promox on Morefine N6000 16GB 512GB

2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...