ping questions


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ping questions
# 1  
Old 02-17-2012
ping questions

Hi All,

I used to work on Sun Solaris, On the Solaris, when I do ping, I used to get the results as

Code:
XYZ is alive

but now I work on Linux. when I do ping. I get the results. For example:

Code:
ping nyus -c 3
PING nyus (x.x.x.x) 56(84) bytes of data.
64 bytes from nyus (x.x.x.x): icmp_seq=0 ttl=64 time=0.113 ms
64 bytes from nyus (x.x.x.x): icmp_seq=1 ttl=64 time=0.095 ms
64 bytes from nyus (x.x.x.x): icmp_seq=2 ttl=64 time=0.103 ms
--- nyus ping statistics ---


But if I want the results as xyz is alive. Please advice.

Thanks.

Last edited by Scott; 02-18-2012 at 05:43 AM.. Reason: Code tags, please...
# 2  
Old 02-17-2012
Code:
ping -c 1 $hostname > /dev/null && echo "$hostname is alive"

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 02-17-2012
The man page advises to use a count and a deadline to check wether a host is alive.

Something like this will be more reliable:
Code:
$ ping -c 10 -w 10 myhost >/dev/null && echo "myhost is alive"
myhost is alive

Please note that a host you can ping is alive, but you can't assume a host is down just because you can't ping it. (My apology if that was obvious to you.)
# 4  
Old 02-19-2012
Are you sure that "ping" returns a non-zero exit code when the target does not reply. Tried on HP-UX.
Code:
ping deadhost -n 2 && echo "host is alive"

PING deadhost: 64 byte packets

----deadhost PING Statistics----
2 packets transmitted, 0 packets received, 100% packet loss
host is alive

It does return a non-zero exit code if the hostname is invalid.
# 5  
Old 02-19-2012
Quote:
Originally Posted by methyl
Are you sure that "ping" returns a non-zero exit code when the target does not reply. Tried on HP-UX.
It does on Linux, I can't speak for HP-UX bugs.
# 6  
Old 02-20-2012
Quote:
I can't speak for HP-UX bugs.
Not a HP-UX bug as such. I can remember "ping" behaving like this in Berkeley unix and Unix System V. As long as you gave "ping" a valid task, you had to read the actual output of "ping".

Last edited by methyl; 02-20-2012 at 12:30 PM..
# 7  
Old 02-20-2012
As far as I recall, Solaris is the only Unix OS that returns a short "XYZ is alive" by default.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Ping test sends mail when ping fails

help with bash script! im am working on this script to make sure my server will stay online, so i made this script.. HOSTS="192.168.138.155" COUNT=4 pingtest(){ for myhost in "$@" do ping -c "$COUNT" "$myhost" &&return 1 done return 0 } if pingtest $HOSTS #100% failed... (4 Replies)
Discussion started by: mort3924
4 Replies

2. Shell Programming and Scripting

How to get reason for ping failure using perls Net::Ping->new("icmp");?

Hi I am using perl to ping a list of nodes - with script below : $p = Net::Ping->new("icmp"); if ($p->ping($host,1)){ print "$host is alive.\n"; } else { print "$host is unreacheable.\n"; } $p->close();... (4 Replies)
Discussion started by: tavanagh
4 Replies

3. IP Networking

PING

I am unable to ping my remote server.My server is unable to ping the same. both are able to ping the gateway. both the ip's are on same network.i use a proxy tunnel on my remote server.Help if any clues. (6 Replies)
Discussion started by: oslbhavana
6 Replies

4. Shell Programming and Scripting

Animation Ping on Solaris Like Cisco Ping

Hi, I develop simple animation ping script on Solaris Platform. It is like Cisco ping. Examples and source code are below. bash-3.00$ gokcell 152.155.180.8 30 Sending 30 Ping Packets to 152.155.180.8 !!!!!!!!!!!!!.!!!!!!!!!!!!!!!. % 93.33 success... % 6.66 packet loss...... (1 Reply)
Discussion started by: gokcell
1 Replies

5. Homework & Coursework Questions

Print questions from a questions folder in a sequential order

1.) I am to write scripts that will be phasetest folder in the home directory. 2.) The folder should have a set-up,phase and display files I have written a small script which i used to check for the existing users and their password. What I need help with: I have a set of questions in a... (19 Replies)
Discussion started by: moraks007
19 Replies

6. Linux

Not able to ping

Hi All, Need your help one more time. I am trying to ping a linux machine which is not responding to ping. However traceroute can reach the machine and I can log in to it by ssh. I have checked /proc/sys/net/ipv4/icmp_echo_ignore_all it is already set as "0". It is not happening in the... (1 Reply)
Discussion started by: ailnilanjan
1 Replies

7. IP Networking

can't ping by ip

hi, I m trying to ping ip on the network . The machine is started but i can't access and can't ping it .. But when i restarts that machine that works fine..... can anybody have an idea about this problem ?? if then reply .. thanks (2 Replies)
Discussion started by: tahir23
2 Replies

8. UNIX for Advanced & Expert Users

can't ping IP

hi , i have problem that i can't ping machine , machine is in running state but i can't access or ping it .. but when i restarts that machine it works fine. can anybody have an idea abou this problem .. thanks (1 Reply)
Discussion started by: tahir23
1 Replies

9. AIX

ping

We can ping out but the return never comes back even to localhost ping localhost PING loopback: (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0 ms it just sits there.... any ideas, any files to check (1 Reply)
Discussion started by: csaunders
1 Replies

10. Shell Programming and Scripting

ping -t

I need a script that recieves an IP adress and a number of seconds as arguments. and display a massage if the IP replies or not. (8 Replies)
Discussion started by: jaber87
8 Replies
Login or Register to Ask a Question