[ Index ]

PHP Cross Reference of phpSSH

/ -> ssh-pipes.php (summary)

Implementation of SExec using pipes.

Author: José R. Valverde
File Size: 519 lines (17 kb)
Included or required: 0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

sexec:: (11 methods):
  sexec()
  set_remote_end()
  ssh_passthru()
  ssh_exec()
  ssh_copy()
  ssh_open_shell()
  ssh_open_command()
  ssh_out_expect()
  ssh_close()
  ssh_popen()
  ssh_pclose()


Class: sexec  - X-Ref

NOTE: this is version 1.0! It has not been updated yet to exploit
SSH shared channel facilities.

sexec($this->remote="localhost", $this->password="xxyzzy")   X-Ref
No description

set_remote_end($this->remote, $this->password="xxyzzy")   X-Ref
No description

ssh_passthru($command, &$status)   X-Ref
Execute a single command remotely using ssh and
display its output, optionally returning its exit
status (like passthru)

This function is intended to be used as a one-time
all-at-once non-interactive execution mechanism which
will run the command remotely and display its output.

If you try to issue an interactive command using this
function, all you will get is unneccessary trouble. So
don't!

This might be done as well using a pipe on /tmp and
making the command 'cat' the pipe: when ssh runs, it
runs the command 'cat' on the pipe and hangs on read.
Then we just need a thread to open the pipe, put the
password and close the pipe.
This other way the password is never wirtten down.
But, OTOH, the file life is so ephemeral that most
of the time it will only exist in the internal system
cache, so this approach is not that bad either.


ssh_exec($command, &$out)   X-Ref
Execute a remote command using SSH

This function sort of mimics rexec(3) using SSH as the transport
protocol.

The function returns the exit status of the remote command, and
appends the remote job output to an optional argument.

This function is intended to be used as a one-time
all-at-once non-interactive execution mechanism which
will run the command remotely and return its output.

If you try to issue an interactive command using this
function, all you will get is unneccessary trouble. So
don't!


ssh_copy($origin, $destination, $this->password)   X-Ref
Copy a file or directory from one source to a destination

This function copies source to dest, where one of them is a
local filespec and the other a remote filespec of the form
[user@]host:path

If the original source is a directory, it will be copied
recursively to destination (hence easing file transfers).

The function returns TRUE on success or FALSE on failure.


ssh_open_shell()   X-Ref
Open an SSH connection to a remote site with a shell to run
interactive commands

Connects to a remote host and opens an interactive shell session
with NO controlling terminal.

Returns a process_control array which contains the process resource
ID and an the standard file descriptors which the caller may use to
interact with the remote shell.


ssh_open_command($command)   X-Ref
Open an SSH connection to run an interactive command on a remote
site

Connects to a remote host and runs an interactive command
with NO controlling terminal.

Returns a process_control array which contains the process resource
ID and an the standard file descriptors which the caller may use to
interact with the remote shell.

ssh_out_expect($p, $expr="^# ")   X-Ref
Get output until we reach a given regular expression


ssh_close($p)   X-Ref
Close an SSH interactive session


ssh_popen($command, $mode)   X-Ref
Execute a remote command and keep an unidirectional stream
contact with it.

This routine mimics 'popen()' but uses ssh to connect to
a remote host and run the requested command.

ssh_pclose($f)   X-Ref
No description



Generated: Wed May 25 19:30:43 2005 Cross-referenced by PHPXref 0.4.1