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, 23:56 (5864 days ago) @ woddrazen

Hi,


Can you please try something like this:
[code]
...
$ssh->{Timeout} = 5;
$ssh->Connect();

$ssh->WaitFor('weonlydo@linux:~$');
$ssh->Send( ls -al\n );

use Win32::OLE;
$Win32::OLE::Warn = 3;

do {
print $ssh->Receive();
} while ($@==0);[/code]
I'm not Perl guru. This worked for me but I receive in output error also.


Drazen

Hi Drazen,
The suggested code (actually the timeout property) only resolve Receive hang issue. But it also exits the script after timeout, which doesn't really fix the problem. Here is the screen output:

===== output =========
OLE exception from WeOnlyDo.wodSSHCom.1 :

The current connection has timeout.

Win32::OLE(0.1707) error 0x800a05b4
in METHOD/PROPERTYGET Receive at ....
======================

The purpose of this customized waitfor is to capture all buffered resposne from server after issuing a command which won't return to command prompt and don't have specific pattern to match. It takes CTRL+C to break the command.

What else method you would suggest for this purpose?

Regards,
novanstar


Complete thread: