Net_SSH2::setTimeout PHP Method

setTimeout() public method

$ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout. Setting $timeout to false or 0 will mean there is no timeout.
public setTimeout ( mixed $timeout )
$timeout mixed
    function setTimeout($timeout)
    {
        $this->timeout = $this->curTimeout = $timeout;
    }

Usage Example

Example #1
1
 /**
  * Logs in to a SSH server with the specified credentials,
  * and returns the Net_SSH2 instance.
  *
  * @return 	Net_SSH2 $ssh 
  * @author 	Ronald Rey
  **/
 public static final function getSSH($host, $user, $pass, $timeout)
 {
     $ssh = new Net_SSH2($host);
     if (!$ssh->login($user, $pass)) {
         exit('Login to failed.');
     }
     $ssh->setTimeout($timeout);
     $ssh->write(" ");
     return $ssh;
 }
All Usage Examples Of Net_SSH2::setTimeout