APLawrence - Information and Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds Get APLawrence.com by RSS











(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Home > News Posts > ping like windows dos ping ––>Re: set ping defaultcount?
Printer Friendly Version




News Group Posts

ping like windows dos ping




From: ian@john-richard.co.uk (Ian Peattie)
Subject: Re: set ping default count?
Date: Thu, 01 Feb 2001 11:02:03 GMT
References: <3a772c79.110495317@news.kiva.net>
<3A7732F5.7CCE413F@aplawrence.com>
<95a7sr$b36$1@nnrp1.deja.com> In article <95a7sr$b36$1@nnrp1.deja.com>, Robert Carnegie <rja.carnegie@mailexcite.com> wrote: >In article <3A7732F5.7CCE413F@aplawrence.com>, > Tony Lawrence <tony@aplawrence.com> wrote: >> You need a shell script named "ping" in /bin (which precedes >> /usr/bin in PATH) that does: >> >> /usr/bin/ping -c 5 $* >> >> Watch out that this doesn't break some other script, though..

>A version that accepts a default _and_ lets you override
>it with an explicit "-c" parameter earns bonus points,
>I suppose; without hands on at the moment, I think that
>might call for a script, that can parse the command line
>for a "-c" parameter whose value will be stored to a
>variable initialised to 5, and then throw that and the
>other parameters at the real "ping" - which I wouldn't
>expect to be cooperative when handed two "-c" parameters,
>a default and a real one, although trying it out won't
>do any harm.

Bonus points to Tony, then, as his suggestion does that. Most commands will 
use getopt(S), or similar, internally to loop though their arguments, which 
will normally cause the last appearance of a particular argument to override 
any previous ones. So if you run:

   ping -c5 -c4 -c3 -c2 -c1 www.sco.com

The -c1 will be the option that ping uses.

Generally commands will accept multiple redundant arguments without complaint. 
You could, if you had too much time on your hands, sit and type in:

  l -t -t -t -t -t -t -t -t -t -t -t -t -t -t -t 














and it will function equivalently to 'l -t'.  

However, some commands do attach special meaning to the same argument being 
used multiple times. For example, to enable debugging, a command might produce 
one level of debugging when run as 'cmd -d' but a higher level when run as 
'cmd -d -d'.

   Ian.

-- 
Ian Peattie                             ian@john-richard.co.uk
Edinburgh, Scotland.


If this page was useful to you, please click to help others find it:  

Your +1's can help friends, contacts, and others on the web find the best stuff when they search.

Comments?



Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

g_face.jpg

This post tagged:

       - SCO_OSR5




Unix/Linux Consultants

Skills Tests

Guest Post Here