Can someone explain what these arguments mean?

Hi folks,

I am betting this is a very simple thing, but I admit i don't know the proper terms to search it out correctly.

I am self-learning at work.
I've come on a section of code in a script:

/usr/sbin/ping $dev 5 2 2>&1 | /usr/xpg4/bin/egrep -s "unknown host|no answer"

What I can't figure out(or search out) is what the arguments "5 2 2>&1" are doing??

I thought it was setting 2 '5 byte messages' with a time to live of 2...something.
But I can not find any data to support that or otherwise explain what's going on here.

So thanks to anyone who can explain this.

Marc

Check man ping on that system (I'm guessing it is Solaris) to get explanation of 5 2 . 2>&1 is a redirection technique, allowing to "merge" standard error messages into standard output stream.

1 Like

2>&1 directs standard error to standard output.

For the "$dev 2 5" arguments you will need to read the manual page ("man ping") for your system. My system does not support that usage.

It would appear that "$dev" is the hostname, and "2 5" possibly the timeout and count.

Check the man page.

1 Like

The ping command on AIX uses those two parameters.

From the man page:

5
PacketSize
Specifies the number of data bytes to be sent. The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data. This parameter is included for compatibility with previous versions of the ping command.

2
Count
Specifies the number of echo requests to be sent (and received). This parameter is included for compatibility with previous versions of the ping command.

Example: ping server 5 2
PING server (xxx.xxx.xxx.xxx): 5 data bytes
13 bytes from xxx.xxx.xxx.xxx: icmp_seq=0 ttl=64
13 bytes from xxx.xxx.xxx.xxx: icmp_seq=1 ttl=64

--- server ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss

1 Like

Thank you all for giving me the answer here! I had not tried this on an AIX box. Only a virtual linux box and a Solaris server I have access too.