On Wed, 06 Feb 2002 03:26:27 +0800
begin  "Tom Wilson" <[EMAIL PROTECTED]> spewed forth:

> Hi all,
> 
> First, my script abilility rests in /dev/null.  That being said, what I
> am *trying* to do is get a text file with a list of MAC addresses and
> the corresponding IP's for certain ranges of IP's.  
> 
> Part of my solution:
> ---------------------------
> for i in `seq 100 120`; do
>      ping -c 5 -w 5 192.168.0.$1 | arp >> macadd.txt

Let's analyze this line for a second.  You ping an address 5 times.  (I'll
ignore the typo and assume it's $i not $1).  Then pass it to arp as an
argument.  Or do you?

Try this:
ping -c 1 192.168.0.2
ping -c 1 192.168.0.3
(let's assume both can be pung)
echo 192.168.0.2 | arp

oops. looks like arp doesn't know how to accept piping of an argument. 
Several utilities have this problem.

Make the line:
ping -c 1 -w 2 192.168.0.$i && arp -n 192.168.0.$i | grep -v Iface >>
mac.txt

the changes: we really don't need to ping something 5 times to get it's
MAC address, and a 2 second wait is really too long, but better than 5. 
The && says, if the ping exited unsuccessfully (we couldn't ping the
system), then we don't want to run arp, but if successful, we do.  Then
forcefeed arp the same IP so we only get one line.  The -n is, well, do
you really want to resolve the hostname?  The grep -v gets rid of the
Header line.


> done
> ---------------------------
> 
[snip]

Ciao,

David A. Bandel
-- 
Focus on the dream, not the competition.
                -- Nemesis Racing Team motto
Internet (H323) phone: 206.28.187.30
_______________________________________________
Linux-users mailing list - http://linux.nf/mailman/listinfo/linux-users
Subscribe/Unsubscribe info, Archives,and Digests are located at the above URL.

Reply via email to