Hi
Obviously first time poster here. I have been set the task of creating a network diagram for each of our clients in the business i work for. After identifying ip adresses of firewalls name servers and the like im got to the point where i found it impracticle to go through 254 ip address and check for a responce. (Im doing this work remotley through a VPN/Putty combination)
As im new to scripting (Only started about a week ago) im not sure on much of the basics so have been making my way through man pages and google sites all week
So my question. So far, my code is as follows:
#!/bin/bash
#Author: John Crombie
#Small script to ping all ip's within a range specified and to write to file all ips that return a responce.
echo Debugging!
echo xxx.xxx.xxx.x Successfull Pings:>/home/johnc/Scripts/inprogress/ipSearch/ping.log
#for i in {1..254}
for i in {1..5}
do
ping -c 1 xxx.xxx.xxx.$i>>/home/johnc/Scripts/inprogress/ipSearch/ping.log
done
(Replace xxx with correct IP naturally)
Now the problem. While it does what i want the log files is a little clumsy to go through so i want to do the following:
- send all ip address with no responce to ping to /dev/null
- go from the sample output below to just the ip address of the successfull ping attempts.
EXAMPLE:
Before:
PING xxx.xxx.xxx.253 (xxx.xxx.xxx.253) 56(84) bytes of data.
--- xxx.xxx.xxx.253 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
PING xxx.xxx.xxx.254 (xxx.xxx.xxx.254) 56(84) bytes of data.
64 bytes from xxx.xxx.xxx.254: icmp_seq=1 ttl=63 time=33.3 ms
--- xxx.xxx.xxx.254 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 33.368/33.368/33.368/0.000 ms
After:
xxx.xxx.xxx.254
So the thoughts i had on this was that i need to firstly add some additional constraints on the ping command and then to pipe the ping.log file through a grep comman of some kind and finishing of with some sort of restrictive redirection on the results of grep....
But i would really value some input.
Let me know if i can provide anymore info or this inst clear. Or its in the wrong forum?
Regards,
John.