src/Controller.php
public function run($commands, $callback = null)
	{
		if (!$this->ssh->isConnected())
			throw new NotConnectedException();

		if (is_array($commands))
			$commands = implode(' && ', $commands);

		if ($callback === null)
			$output = '';

		$this->ssh->exec($commands, false);

		while (true) {
			if (is_null($line = $this->readLine())) break;

			if ($callback === null)
				$output .= $line;
			else
				call_user_func($callback, $line, $this);
		}

		if ($callback === null)
			return $output;
		else
			return null;
	}
public function run($commands, $callback = null)
	{
		if (!$this->ssh->isConnected())
			throw new NotConnectedException();

		if (is_array($commands))
			$commands = implode(' && ', $commands);

		if ($callback === null)
			$output = '';

		$this->ssh->exec($commands, false);

		while (true) {
			if (is_null($line = $this->readLine())) break;

			if ($callback === null)
				$output .= $line;
			else
				call_user_func($callback, $line, $this);
		}

		if ($callback === null)
			return $output;
		else
			return null;
	}
public function run ( $ commands , $ callback = null ) { if ( ! $ this -> ssh -> isConnected ( ) ) throw new NotConnectedException ( ) ; if ( is_array ( $ commands ) ) $ commands = implode ( ' && ' , $ commands ) ; if ( $ callback === null ) $ output = '' ; $ this -> ssh -> exec ( $ commands , false ) ; while ( true ) { if ( is_null ( $ line = $ this -> readLine ( ) ) ) break ; if ( $ callback === null ) $ output .= $ line ; else call_user_func ( $ callback , $ line , $ this ) ; } if ( $ callback === null ) return $ output ; else return null ; }
Run a ssh command for the current connection.

@param string|array $commands
@param callable $callback

@throws NotConnectedException If the client is not connected to the server

@return string|null
Run a ssh command for the current connection .