Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > pinging in terminal / how to?

pinging in terminal / how to?
Thread Tools
Junior Member
Join Date: Jan 2002
Location: Geelong Australia
Status: Offline
Reply With Quote
Apr 22, 2003, 05:27 AM
 
I have this command


/sbin/ping -nqc 1 "192.168.0.5" | sed -n 's|.*/\(.*\) .*|\1|p'

where the 192.168.0.5 part corresponds to an address on my network.

If the ip address is valid, the above returns a time in ms of the ping.....

if not it times out and returns 0 after 10 - 20 sec....

my question is can I speed up this timeout?

I want it to time out after abour 1 second.....

is this possible?

Thanks in advance

James
Windows: Been There Done That , Why go Back?
MAC
     
Clinically Insane
Join Date: Apr 2000
Status: Offline
Reply With Quote
Apr 22, 2003, 06:02 AM
 
IIRC, -w is maxwait... defaulted to 10... change that?

man ping

I can't remember, and I'm in OS9 right now.
     
Junior Member
Join Date: Jan 2002
Location: Geelong Australia
Status: Offline
Reply With Quote
Apr 22, 2003, 06:13 AM
 
Thanks Cipher,

No luck though...

I am not to familiar with the terminal...

Would you be able to help me next time your in X?

Thanks heaps

James
Windows: Been There Done That , Why go Back?
MAC
     
Dedicated MacNNer
Join Date: Dec 2002
Location: someplace
Status: Offline
Reply With Quote
Apr 22, 2003, 08:14 AM
 
Originally posted by James Mullins:
I have this command


/sbin/ping -nqc 1 "192.168.0.5" | sed -n 's|.*/\(.*\) .*|\1|p'

where the 192.168.0.5 part corresponds to an address on my network.

If the ip address is valid, the above returns a time in ms of the ping.....

if not it times out and returns 0 after 10 - 20 sec....

my question is can I speed up this timeout?

I want it to time out after abour 1 second.....

is this possible?
To ping with a timeout of one second, sending a single ping:
ping -i 1 -c 1 192.168.0.5

man ping for more details:
Code:
-c count Stop after sending (and receiving) count ECHO_RESPONSE packets. -i wait Wait wait seconds between sending each packet. The default is to wait for one second between each packet. This option is incom- patible with the -f option.
     
Junior Member
Join Date: Jan 2002
Location: Geelong Australia
Status: Offline
Reply With Quote
Apr 22, 2003, 08:23 AM
 
Thanks for the reply gator,

but this command does not work if the ip address is not valid.

I want to time out if there is no computer at that ip address rather than waiting the full 10 sec (default timeout)

Cheers James

Any other ideas?

Greatly appreciated
Windows: Been There Done That , Why go Back?
MAC
     
rkt
Mac Enthusiast
Join Date: Oct 2000
Status: Offline
Reply With Quote
Apr 22, 2003, 09:58 AM
 
Originally posted by Cipher13:
IIRC, -w is maxwait... defaulted to 10... change that?
yes and no...

-w is the correct switch, and is listed in the man page *but* the ping binary that ships with macosx doesn't support it...
     
Dedicated MacNNer
Join Date: Dec 2002
Location: someplace
Status: Offline
Reply With Quote
Apr 22, 2003, 10:44 AM
 
fink has two alternatives to the OS X-provided ping binary. You may want to try one of those to accomplish you aims:
Code:
fping 2.4b2-1 Pings a number of hosts at one time mtr 0.44-1 Combines 'traceroute' and 'ping' functionality
     
Junior Member
Join Date: Jan 2002
Location: Geelong Australia
Status: Offline
Reply With Quote
Apr 23, 2003, 08:19 AM
 
Thanks for your help guys!

fping looks great, I downloaded it but cannot get it working

any help would be greatly appreciated, I am just getting used to the terminal and I need a bit of help!

Thanks James
Windows: Been There Done That , Why go Back?
MAC
     
rkt
Mac Enthusiast
Join Date: Oct 2000
Status: Offline
Reply With Quote
Apr 24, 2003, 10:33 AM
 
Originally posted by James Mullins:
fping looks great, I downloaded it but cannot get it working
fping works okay for me here... this is what i did:

% cd /tmp
% curl -O http://www.fping.com/download/fping-2.4b2_to.tar.gz
% gnutar -zxf fping-2.4b2_to.tar.gz
% cd fping-2.4b2_to
% ./configure
% make
% sudo make install
% sudo chmod 4555 /usr/local/sbin/fping
% rehash
% fping www.apple.com

let me know if you have any questions...
(Last edited by rkt; Apr 24, 2003 at 10:38 AM. )
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:05 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2