![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bash Script to check Remote Host Connection | zulfikarmd | UNIX for Dummies Questions & Answers | 5 | 04-16-2008 07:53 AM |
| How to delete the files from local host to remote host | krishna176 | SUN Solaris | 3 | 03-24-2007 04:48 PM |
| disk discovery | fredao | SUN Solaris | 2 | 01-08-2007 01:51 PM |
| host alias not working: host not found | FunnyCats | UNIX for Advanced & Expert Users | 4 | 05-13-2005 05:36 PM |
| QNX host cannot ping SCO host, vice versa | gavon | IP Networking | 2 | 08-20-2001 09:57 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
host discovery using bash
I am trying to make a bash script to scan subnets to see what hosts are available. Is it correct that you can not make the ping command time out less than a second? The script below works, but can take up to 255 seconds which is a bit long
Is there a way to solve this using bash only?<code> subnet=192.168.2. addr=1 while [ $addr -lt 256 ]; do ping -c 1 -t 1 $subnet$addr > /dev/null && echo Found $subnet$addr let addr=addr+1 done </code> |
|
||||
|
I think I saw a program called "uping" or "mping" which had more fine-grained timing controls (I think part of the MRTG suite ... could have been "fastping" too).
Two other ideas come to mind. 1. Run asynchronously. Spawn off a big bunch of pings and even if some of them take one second or more, the whole bunch will finish in one or two seconds (provided you have the CPU and bandwidth to run enough of them in parallel). Code:
subnet=192.168.2. for addr in `seq 1 1 255 `; do ( ping -c 1 -t 1 $subnet$addr > /dev/null && echo Found $subnet$addr ) & done |
|
||||
|
I think this is the "fast ping" I was thinking of. fping.com Looks like it can handle the whole problem you have.
It's used by a system called SmokePing, by the MRTG author, wich is however apparently a separate module. SmokePing - Smokeping::probes::FPing |
|
||||
|
Era, I am so sorry for the late reply.
Your script is perfect! Thanks very much for the input. I really just want to know where my machines are on the network . My DHCP server is so basic that it does not even show me the current leases. Last edited by bronkeydain; 03-23-2008 at 09:26 PM.. Reason: fix typo |
|
||||
|
If it's your network then you could also simply do a ping to the broadcast address, although I guess a some modern machines will no longer respond to broadcast ping (at least it's an option).
|
![]() |
| Bookmarks |
| Tags |
| ping, ping port, port, port ping |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|