Can someone explain what these arguments mean? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Can someone explain what these arguments mean?

Shell Programming and Scripting


Tags
shell commands

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-17-2012
Marc G Marc G is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 23 April 2013, 2:45 PM EDT
Posts: 47
Thanks: 15
Thanked 1 Time in 1 Post
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:

Code:
/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
Sponsored Links
    #2  
Old 12-17-2012
bartus11's Avatar
bartus11 bartus11 is offline Forum Staff  
Moderator
 
Join Date: Apr 2009
Last Activity: 28 July 2014, 3:47 PM EDT
Posts: 3,707
Thanks: 7
Thanked 1,141 Times in 1,112 Posts
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.
The Following User Says Thank You to bartus11 For This Useful Post:
Marc G (12-17-2012)
Sponsored Links
    #3  
Old 12-17-2012
Scott's Avatar
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 29 July 2014, 2:18 AM EDT
Location: Zürich
Posts: 8,437
Thanks: 328
Thanked 1,030 Times in 901 Posts
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.
The Following User Says Thank You to Scott For This Useful Post:
Marc G (12-17-2012)
    #4  
Old 12-17-2012
in2nix4life's Avatar
in2nix4life in2nix4life is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 28 July 2014, 4:10 PM EDT
Location: East Coast
Posts: 602
Thanks: 1
Thanked 172 Times in 158 Posts
The ping command on AIX uses those two parameters.

From the man page:


Code:
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

The Following User Says Thank You to in2nix4life For This Useful Post:
Scott (12-17-2012)
Sponsored Links
    #5  
Old 12-17-2012
Marc G Marc G is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 23 April 2013, 2:45 PM EDT
Posts: 47
Thanks: 15
Thanked 1 Time in 1 Post
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.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can someone explain this for me? bashily Shell Programming and Scripting 2 03-18-2012 12:18 PM
grep with two arguments to arguments to surch for Cybertron Shell Programming and Scripting 1 04-11-2011 04:46 AM
Can anyone please explain this?? Diddy Shell Programming and Scripting 3 02-02-2011 03:01 AM
can any one explain this example maxim42 Shell Programming and Scripting 4 05-27-2009 01:43 PM
if [ $? -eq 0 ] .. can someone explain this? ranjita.c Shell Programming and Scripting 5 10-03-2006 07:50 PM



All times are GMT -4. The time now is 06:42 AM.