On March 1, 2004 06:54 am, Marty Landman wrote: > I'm reposting my previous msg with the exec included as this might make > things clearer./Marty > > I recently wrote a bash script to find the active ip addr's on my lan by > pinging every possibility on my class C network. This works nicely, only > taking about 15 seconds of wall time to complete. > > The code is: > > #!/bin/bash > > pingEm() > { > echo "preparing pings" > for((i=1;i<255;i++)) > do > echo "ping -c1 192.168.0.$i > $$/$i &" >> pingEmAll.$$ > done > echo "start pinging" > chmod +x pingEmAll.$$ && `./pingEmAll.$$` > } > > findEm() > { > for((i=1;i<255;i++)) > do > awk '/64 bytes from /' $$/$i > ans > awk '{ print length($0) }' ans > len > if [ `more len` ] > then > echo "$i is on the network" > fi > done > } > > mkdir $$ && pingEm > findEm > rm -r $$ & rm pingEmAll.$$ ans len > > echo End of story > > > The output looks like this: > > $ ./findIps > preparing pings > start pinging > 1 is on the network > 3 is on the network > 7 is on the network > 160 is on the network > 240 is on the network > End of story > $ > > Is there any way that I could also discover the names of each of these > active network locations? > > > Marty Landman Face 2 Interface Inc. 845-679-9387 > FormATable DB: http://face2interface.com/Products/FormATable.shtml > Make a Website: http://face2interface.com/Home/Demo.shtml > Free Formmailer: http://face2interface.com/Products/Formal.shtml Hi Marty, ping cannot resolve a name, it can resolve a name to IP prior to sending the packet, but it really doesn't care about names. Presuming your talking hostnames, and not netbios, and if this is a closed network where you already know the machines, you could ping by name. Other than that, you need to incorporates something like feed the returned IP's to 'dig' (or similar) and have it do a revers lookup. (presuming your DNS has proper revers tables in it. for each $IP_ADDRESS ping returns, feed to: dig -x $IP_ADDRESS |grep -A1 "ANSWER SECTION"|grep -v "ANSWER SECTION"|awk '{print $5}' (leaves a trailing "." but it's a start...) You may want to look at 'ping -b' so send a broadcast ping, then collect the results. (won't help the name resolution at all.) -- Pete Nesbitt, rhce -- redhat-list mailing list unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe https://www.redhat.com/mailman/listinfo/redhat-list