Net_SSH2::write PHP Method

write() public method

Inputs a command into an interactive shell.
See also: self::read()
public write ( string $cmd ) : boolean
$cmd string
return boolean
    function write($cmd)
    {
        if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
            user_error('Operation disallowed prior to login()');
            return false;
        }
        if (!($this->bitmap & NET_SSH2_MASK_SHELL) && !$this->_initShell()) {
            user_error('Unable to initiate an interactive shell session');
            return false;
        }
        return $this->_send_channel_packet($this->_get_interactive_channel(), $cmd);
    }

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::write