cutter has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use Net::SSH::Perl; #Use this perl mod to create the SSH session. use Net::SSH::W32Perl; my $host = ""; my $user = ""; my $pw = ""; sub error { die "ERROR! ERROR! ERROR! @_"; } sub ssh_cmd{ my $ssh = new Net::SSH::W32Perl($host); $ssh->login($user, $pw); my $cmd = "./test_alarm.pl > test_alarm.out 2>&1"; my ($out, $err, $exit) = $ssh->cmd($cmd,"\n"); } my $TIMEOUT = 2; # seconds eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm $TIMEOUT; ssh_cmd(); alarm 0; }; if ($@) { if($@ eq "alarm\n") { error("OPERATION TIMED OUT!"); } else { error("your_code() generated errors: $@"); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Alarm Timer Win32
by puploki (Hermit) on Sep 19, 2005 at 18:46 UTC | |
by cutter (Acolyte) on Sep 19, 2005 at 19:06 UTC | |
|
Re: Alarm Timer Win32
by polypompholyx (Chaplain) on Sep 19, 2005 at 18:53 UTC | |
|
Re: Alarm Timer Win32
by PodMaster (Abbot) on Sep 20, 2005 at 14:35 UTC | |
by cutter (Acolyte) on Sep 20, 2005 at 16:55 UTC |