Quote:
Originally Posted by arch
about the arp stuff try arpwatch - it's harvest mac addresses in combination with ip - one drawback is that it omit zeros if you have mac for exmp: 0b:bla:bla ... it print it in the log in form of b:bla:bla.
btw for a week now i try some sh scripting and .. want to share :-p
here it is:
Code:
#!/bin/sh
val=1
count=255
echo input ip range
read ip
while [ $val -le $count ]
do
echo ping ip $ip.$val
`/sbin/ping -c 1 $ip.$val > /dev/null 2>&1`
if echo $?
then
echo ip is in use
echo $ip.$val >> used
else
echo ip is not in use
echo $ip.$val >> unused
fi
val=`expr $val + 1`
done
i know..it's lame.. :-p
P.S by ip range i mean..ip block e.g you input 192.168.0 and that's it.. to stop it you have to suspend it.. or killed or whatever..
if use ctr+c well.. you fast though all ip's
|
Arch, I ran your script and I found a problem with it. Every time that I ran your script, it showed that all IPs were being used even though some IPs were not being used. Turns out that the problem was with your "if statement". You are not checking to see whether ping returned 0 (ping got a reply) or 1 (ping did not get a reply). So to fix that I went ahead and corrected your "if statement" and did the following:
Code:
ping -c 1 $ip.$val > /dev/null
if [ "$?" -eq 0 ] ; then
After changing the "if statement", your script is working great!!!
Just like I needed!
Now, I'll probably be expanding this script to perhaps add more functionality to it.