From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Arijit
Das
Sent: 13 March 2006 13:30
To: [email protected];
[email protected]
Subject: Timeing Out a Command - how to?

> Is there any way to time out a unix command?
>  
> Its something like this... I want my PerlPgm <might_hang.pl> to be
killed by the shell (sh/bash/csh) if my 
> PerlPgm fails to finish off by 300 elapsed seconds.
>  
> Something like
>  
> <timeout_shell_command> -timeout 300 might_hang.pl
>  
> This should execute might_hang.pl normally but if might_hang.pl fails
to finish off by 300 elapsed secs, it 
> should kill the might_hang.pl process.
>  
> I know that this can be achieved from inside might_hang.pl using
alarms, but I needed to achieve that through a > bourne shell i.e. the
invoker of the Perl program (might_hang.pl).
>  
> Any thoughts about how this can be achieved...?

You seem to already know the easiest way to do this ('perldoc -f
alarm'), but you don't say why don't want to (or perhaps can't) use this
method. If you did it might make it easier to answer your question.
However, some variation on the following should do the trick.

perl might_hang.pl
pid=$!
sleep 300
kill $pid

The end result is very similar to using alarm, except that you can
decide what signal to send.

HTH

-- 
Brian Raven 


=================================
Atos Euronext Market Solutions Disclaimer
=================================
The information contained in this e-mail is confidential and solely for the 
intended addressee(s). Unauthorised reproduction, disclosure, modification, 
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message do not 
necessarily reflect those of Atos Euronext Market Solutions.

L'information contenue dans cet e-mail est confidentielle et uniquement 
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. 
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail 
vous parvient par erreur, nous vous prions de bien vouloir prevenir 
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre 
systeme. Le contenu de ce message electronique ne represente pas necessairement 
la position ou le point de vue d'Atos Euronext Market Solutions.


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to