in reply to Re: net ssh loop
in thread net ssh loop

Hi, exactly same error happens with simpler code.

<code> my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); my ($LS_OUT, $LS_ERR, $LS_EXIT) = $ssh->cmd('ls -la'); print "This is END where i want to see\n"; <code> _jho

Replies are listed 'Best First'.
Re^3: net ssh loop
by salva (Canon) on Jul 21, 2010 at 12:47 UTC
    First, to include code in your posts use <code>your code here</code>, there is a backslash in the closing tag!

    Regarding your original question, wrap the code that can fail inside eval:

    eval { my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); my ($LS_OUT, $LS_ERR, $LS_EXIT) = $ssh->cmd('ls -la'); }; $@ and print "SSH failed: $@"; print "This is END where i want to see\n"
      Hi, create, it works thanks. -jho
Re^3: net ssh loop
by Anonymous Monk on Jul 21, 2010 at 12:03 UTC

    i have tried already. <code> my $ssh = Net::SSH::Perl->new($host); if ($ssh->login($user, $pass)){ my ($LS_OUT, $LS_ERR, $LS_EXIT) = $ssh->cmd('ls -la'); }else{ print "The END\n";} <code>