Blog |Follow Nick on Twitter| About
 

I'm working away from home a lot at the moment :-( so site updates are slow.

Anway one of the things I've needed was a script that could ping stuff from a Nokia Box ... I'm quite proud of my work so here it is... simply write a file called "ips.txt" with ip addresses in it eg:

192.168.1.1 10.1.1.1 10.10.9.8

ftp or sftp the files onto the nokia ( /var/admin is a good place) and run ./nokia.sh... you'll get something like...

FIREWALL[admin]\# ./nokia.sh PINGING 192.168.1.1 \~ PINGING 10.10.9.8 DONE ! FIREWALL[admin]\#

*If you have problems running nokia.sh, like *./nokia.sh: Permission denied. then do a chmod 700 nokia.sh***

..and in /var/admin (or where ever you put it) you'll get a results.txt file (actually hostname-results.txt, so in my example FIREWALL-results.txt)

This is an extract of what you get...

PINGING From FIREWALL To 192.168.1.1 \~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~ PING Tue May 3 13:37:51 2005 192.168.1.1: 64 data bytes

----Tue May 3 13:37:54 2005 192.168.1.1 PING Statistics---- 4 transmitted, 0 received, 100.00% packet loss. 3.024 seconds elapsed, throughput = 0.00 packets/sec; 0.000 bps. \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# PINGING From FIREWALL To 10.10.9.8 \~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~ PING Tue May 3 13:37:54 2005 10.10.9.8: 64 data bytes EchoReply from 10.10.9.8: len=64 ttl=255 seq=0 time=1.155 ms. EchoReply from 10.10.9.8: len=64 ttl=255 seq=1 time=0.357 ms. EchoReply from 10.10.9.8: len=64 ttl=255 seq=2 time=0.370 ms. EchoReply from 10.10.9.8: len=64 ttl=255 seq=3 time=0.484 ms. ----Tue May 3 13:37:58 2005 10.10.9.8 PING Statistics---- 4 transmitted, 4 received, 0.00% packet loss. 3.025 seconds elapsed, throughput = 1.32 packets/sec; 888.638 bps. round-trip (ms) min/avg/max = 0.357/0.592/1.155 var/sdev/skew/kurt = 0.144/0.380/0.701/1.276

cool ! - here's the script - copy all of the below into nokia.sh ;)

\#!/bin/sh \# Test Nokia Ping Script by [NICK] \# www.linickx.com !!! CONFIG=./ips.txt IPADDRESS=\`cat \$CONFIG\` HOSTNAME=\`hostname\` RESULTS=./\$HOSTNAME-results.txt echo \$HOSTNAME \> \$RESULTS echo "=============" \>\> \$RESULTS for i in \$IPADDRESS do echo "\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#" \>\> \$RESULTS echo "PINGING From \$HOSTNAME To \$i" \>\> \$RESULTS echo "\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~\~" \>\> \$RESULTS echo "PINGING \$i" ping -c 4 \$i \>\> \$RESULTS done echo "DONE !"

 

 
Nick Bettison ©