Download the PHP package cullylarson/ssh-commands without Composer
On this page you can find all versions of the php package cullylarson/ssh-commands. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cullylarson/ssh-commands
More information about cullylarson/ssh-commands
Files in cullylarson/ssh-commands
Package ssh-commands
Short Description A library for executing remote commands, via SSH. Supports exit status, standard output, and error output.
License MIT
Homepage https://github.com/cullylarson/ssh-command
Informations about the package ssh-commands
SSH Commands
A library for executing remote commands, via SSH, with support for exit codes, standard output, and error output. It fills in a gap present in the PECL ssh2 library.
Install
Usage
-
Create an ssh2 connection resource.
If you're using RSA, and you got an auth error, you might need to run this command:
-
Create an instance of
Cully\Ssh\Command
, passing your connection resource to the constructor. -
Execute your command. The
exec
function takes the command you want to execute (e.g.ls
), and optionally, the current working directory (the folder from which you want to execute the command), and an array of environment variables to make available to the command. -
Alternatively, you can execute commands using the
execTerm
function. This exposes all of the parameters that ssh2_exec takes, except for the connection resource (since it was passed in the construtor), and$cwd
. - At this point, you have access to a few results:
The exec
Function
-
$command
(string) The command you want to execute (e.g.ls
). -
$cwd
(string) (optional, default: null) The current working directory (the folder you want to execute the command in). $env
(array) (optional, default: []) An array of environment variable that you want to make available to the command.
The execTerm
Function
-
$command
(string) The command you want to execute (e.g.ls
). -
$cwd
(string) (optional, default: null) The current working directory (the folder you want to execute the command in). - The rest of the parameters are the same as those passed to ssh2_exec.