Is there a simple way for me to make 'ping name.place.net' run just 5
times and end on its own?
Nathan / Theatre Effects
www.theatrefx.com
Oh, I get it- you want the DEFAULT behaviour of ping to be as
though you had added the -c 5.
Sure.
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..
--
Tony Lawrence (to...@aplawrence.com)
SCO/Linux articles, help, book reviews, tests,
job listings and more : http://www.pcunix.com
If it's just for your own use, you can call the script by a
different name - "pling" might amuse. Or just set a
shell alias that says "when I say 'ping' I mean 'ping -c5'".
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.
Most ambitious would be a project that runs in the background so you don't
have to sit and wait, and perhaps pops up the result
(success/failure/response time) in front of the next available shell prompt,
like the "You have mail" message. Not sure if that last is do-able.
Personally I like to knock off useful little scripts that use a few terminal
escape sequences to move the cursor to bottom right and back in order to
display a little by-the-way message, although the bloom fades when I try
host/slave printing through the terminal at the same time, forgetting.
Microsoft Windows "ping" defaults to 4 send-attempts
at 1-second intervals, as I recall.
Some of our on-demand WAN connections are a bit erratic,
and our TCP/IP applications sometimes fail to make contact
unless we rattle the link with a jolly good "ping" first.
Up to a full minute's delay before action starts isn't
unknown - maybe I shouldn't be advertising this, in case,
one day, I'm looking for a job, and an interviewer remembers
what a ramshackle outfit I used to work for.
Sent via Deja.com
http://www.deja.com/
>> 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 i...@john-richard.co.uk
Edinburgh, Scotland.