NetEng PyScript 1: Mass Ping

Python Scripts For Network Engineers 1: Mass Ping

 

import subprocess
import os
import sys

for ping in range(1,32): #(x,y) x = starting range; y = ending range but not including
address = sys.argv[1] + str(ping)
x = subprocess.call([‘ping’, ‘-c’, ’3′, ‘-W’, ’1′, address])
        if x == 0:
                printping to“, address, “OK
        elif x == 2:
                printno response from“, address
        else:
                printping to“, address, “failed!

 

Example:

python ping_script.py 172.16.1.0

Pings would then start from 172.16.1.1 up to 172.16.1.31

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current month ye@r day *

Notify via Email Only if someone replies to My Comment

networking-link.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com.