| #!/bin/sh if [ $# -lt 1 ]; then tests=5 else tests=$1 fi echo "tests:"$tests echo "" base_ip='xx.xx.xx.'#Put this according to where you want to ping for I in $(seq 1 1 $tests) do ip=$base_ip`./generate_ips.py` echo "*********** pinging ip : $ip ***************" result=`ping -c 3 $ip` errors=`echo $result | grep -c errors` if [ $errors -gt 0 ]; then echo "$ip unreachable" else echo "$ip reachable" fi echo $result echo "" done |
The random number generator python file:
| #!/usr/bin/python import random random.seed() x = random.randint(xx,xx)#Specify the range of ips from the base ip print x |
To check, specify the base ip(in the bash script) and the range(in the python file):
| $chmod u+x generate_ips.py $chmod u+x ping_test.sh $./ping_test.sh [Default 5 random ips ping] (OR) $./ping_test.sh 4 [Specifying 4 random ips to ping] |
No comments:
Post a Comment