Timing out Linux commands
From AJS.COM
Timing out Linux commands (such as ssh) isn't as easy as it sounds. Some versions of Linux ship with a timeout wrapper, but it's never quite flexible enough for what I want.
Enter Perl
Perl makes this job quite a lot easier. I rely here on the package TimeOut which you can install by:
cpan TimeOut
as root.
Now try:
perl -MTimeOut -e 'alarm_expired(1,sub{fork or exec @ARGV or die $!;wait})' your command here....
Of course, that leaves your process running if it times out. I'll expand on how to do process control later on when I have the time....
BlogMarks
del.icio.us
digg
Fark
Furl
Newsvine
reddit
Segnalo
Simpy
Slashdot
smarking
Spurl
StumbleUpon
Wists