Re: How to catch error (or exit) when Receive hang (General questions)
Hi,
Here is the full code: Thanks,
===== code ===== (code hang when it print out Count: 4 )
my $ssh = Win32::OLE->new( WeOnlyDo.wodSSHCom.1 );
my $buffer = q{};
$ssh->{Protocol} = 4;
$ssh->{HostName} = 'host01';
$ssh->{Blocking} = 'True';
$ssh->{Login} = 'user';
$ssh->{Password} = 'password';
$ssh->Connect();
$ssh->WaitFor('user@host01:~$ ');
$ssh->Send( command open tty://\n );
ssh->WaitFor('root@devict:/$ ', 10);
print Start to send command... ;
$ssh->Send( command for device\n );
eval {
for (my $i = 1; $i<=20; $i++) {
print Count: $i ;
$buffer .= $ssh->Receive();
print $buffer ;
}
};
if ($@) {
print Error!!!
;
$ssh->Disconnect();
return $buffer;
}
=======================
Alternative to eval{}:
try {
for (my $i = 1; $i<=20; $i++) {
print Count: $i ;
$buffer .= $ssh->Receive();
print $buffer ;
}
}
catch Error with {
print Error!!!
;
$ssh->Disconnect();
return $buffer;
}
Complete thread:
- How to catch error (or exit) when Receive hang - novanstar, 2008-11-04, 02:57
- Re: How to catch error (or exit) when Receive hang - wodDamir, 2008-11-04, 09:00
- Re: How to catch error (or exit) when Receive hang - novanstar, 2008-11-04, 20:19
- Re: How to catch error (or exit) when Receive hang - woddrazen, 2008-11-04, 20:25
- Re: How to catch error (or exit) when Receive hang - novanstar, 2008-11-04, 21:07
- Re: How to catch error (or exit) when Receive hang - woddrazen, 2008-11-04, 23:05
- Re: How to catch error (or exit) when Receive hang - novanstar, 2008-11-04, 23:56
- Re: How to catch error (or exit) when Receive hang - woddrazen, 2008-11-05, 00:03
- Re: How to catch error (or exit) when Receive hang - novanstar, 2008-11-05, 00:46
- Re: How to catch error (or exit) when Receive hang - woddrazen, 2008-11-05, 09:24
- Re: How to catch error (or exit) when Receive hang - novanstar, 2008-11-05, 19:05
- Re: How to catch error (or exit) when Receive hang - wodDamir, 2008-11-05, 19:20
- Re: How to catch error (or exit) when Receive hang - novanstar, 2008-11-06, 19:39
- Re: How to catch error (or exit) when Receive hang - wodDamir, 2008-11-05, 19:20
- Re: How to catch error (or exit) when Receive hang - novanstar, 2008-11-05, 19:05
- Re: How to catch error (or exit) when Receive hang - woddrazen, 2008-11-05, 09:24
- Re: How to catch error (or exit) when Receive hang - novanstar, 2008-11-05, 00:46
- Re: How to catch error (or exit) when Receive hang - woddrazen, 2008-11-05, 00:03
- Re: How to catch error (or exit) when Receive hang - novanstar, 2008-11-04, 23:56
- Re: How to catch error (or exit) when Receive hang - woddrazen, 2008-11-04, 23:05
- Re: How to catch error (or exit) when Receive hang - novanstar, 2008-11-04, 21:07
- Re: How to catch error (or exit) when Receive hang - woddrazen, 2008-11-04, 20:25
- Re: How to catch error (or exit) when Receive hang - novanstar, 2008-11-04, 20:19
- Re: How to catch error (or exit) when Receive hang - wodDamir, 2008-11-04, 09:00