Re: How to catch error (or exit) when Receive hang - WeOnlyDo Discussion board

Re: How to catch error (or exit) when Receive hang (General questions)

by novanstar, Tuesday, November 04, 2008, 20:19 (5623 days ago) @ wodDamir

Hi Damba,
It doesn't work! I have tried the try/catch Perl equivalent (eval) and also tried with Perl Error module (try {} catch Error with {};) both got stuck at Receive . Here is code block using eval: When the count reaches 4, it got stuck, so I believe it's because of Receive , not the for loop.

Thanks,

==== code ====
eval {
for (my $i = 1; $i<=20; $i++) {
print Count: $i

;
$buffer .= $ssh->Receive();
print $buffer

;
}
};

if ($@) {
print Error!!!

;
sleep 5;
$ssh->Disconnect();
return $buffer;
}
=================


Complete thread: