mariname has asked for the wisdom of the Perl Monks concerning the following question:

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 ); } }