Hi I use ssh in my perl code to run shell on remote machine. Perl ssh does not wait for script finishing and continue, meanwhile shell runs on the machine.... It seems that perl ignore a timeout that is defined... I always get : "Didn't return an exit code" Please help. Bellow is a perl code:
$SSH_TIMEOUT = 1200; @SSH_OPTIONS = ("ConnectTimeout=$SSH_TIMEOUT"); my $username = $_[1]; &encodeStr($username); my $password = $_[2]; &encodeStr($password); my $sshCommand = $_[3]; $ssh = Net::SSH::W32Perl->new( $ip, debug => $DEBUG, protocol => $SSH_PROT, options => \@SSH_OPTIONS ); $sshLoginReply = $ssh->login( $username, $password ); my ( $sshCmdReply, $sshCmdErr, $sshCmdExit ) = $ssh->cmd($sshCommand); # check ssh command returns if ( defined($sshCmdReply) ) { $logger->debug( "SSH command \"$sshCommand\" reply from $ip: $sshCmdReply" +); } if ( defined($sshCmdErr) ) { $logger->debug( "SSH command \"$sshCommand\" error from $ip: $sshCmdErr"); } if ( defined($sshCmdExit) ) { $logger->debug( "SSH command \"$sshCommand\" exit code from $ip: $sshCmdEx +it"); # an ssh command exit code exists if ( $sshCmdExit ne $SSH_CMD_SUCCESS ) { return ( $RC_NETWORK_OPERATION_FAILURE, $sshCmdErr ); } else { return ( $RC_SUCCESS, $sshCmdReply ); } } else { # $sshCmdExit doesnt exist - maybe disconnected before exit cod +e returned my $error = "SSH command \"$sshCommand\" to $ip didn't return an exit co +de"; if ( $dsu_type ) { return ( $RC_SUCCESS, $error); } else { $logger->warn($error); return ( $RC_NETWORK_OPERATION_FAILURE, $error ); } }

In reply to Net::SSH::W32Perl timeout by mariname

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.