[ale] Need a bit of help with bash.

Michael Potter michael at potter.name
Thu Feb 10 14:40:07 EST 2011


On Thu, Feb 10, 2011 at 1:37 PM, Pete Hardie <pete.hardie at gmail.com> wrote:
> On Thu, Feb 10, 2011 at 13:20, Chuck Payne <terrorpup at gmail.com> wrote:
>> Guys,
>>
>> I have a script that does a wget, but if a server is not responing,
>> the the script deads. What is the best way to say if host x doesn't
>> return a value after 10 sec to stop.  I seen several example of
>> timeout function, but it looks I need to write a pid is that true?
>>
>>
>
> I've seen this handled by running a ping to the IP first, since ping
> has a timeout
> value already.  It assumes that successful ping will mean successful wget, but
> it might be a start
>
>

Another hint...

$! is the pid of the started process

----------
/path/to/program/myprogram &

myprogpid=$!

sleep 10

kill $myprogpid
----------

That is an academic example only.  I am just throwing that out there
for brainstorming purposes.

I have never used wget, but there is a --timeout option listed on this webpage:
http://linux.about.com/od/commands/l/blcmdl1_wget.htm

-- 
Michael Potter
Replatform Technologies, LLC
+1 770 815 6142
michael at potter.name



More information about the Ale mailing list