class Net_SCP (View source)

Pure-PHP implementations of SCP.

Properties

object $ssh SSH Object
int $packet_size Packet Size
int $mode Mode

Methods

__construct(Net_SSH1|Net_SSH2 $ssh)

Default Constructor.

Net_SCP(Net_SSH1|Net_SSH2 $ssh)

PHP4 compatible Default Constructor.

bool
put(string $remote_file, string $data, int $mode = NET_SCP_STRING, callable $callback = null)

Uploads a file to the SCP server.

mixed
get(string $remote_file, string $local_file = false)

Downloads a file from the SCP server.

_send(string $data)

Sends a packet to an SSH server

string
_receive()

Receives a packet from an SSH server

_close()

Closes the connection to an SSH server

Details

Net_SCP __construct(Net_SSH1|Net_SSH2 $ssh)

Default Constructor.

Connects to an SSH server

Parameters

Net_SSH1|Net_SSH2 $ssh

Return Value

Net_SCP

Net_SCP(Net_SSH1|Net_SSH2 $ssh)

PHP4 compatible Default Constructor.

Parameters

Net_SSH1|Net_SSH2 $ssh

See also

\self::__construct()

bool put(string $remote_file, string $data, int $mode = NET_SCP_STRING, callable $callback = null)

Uploads a file to the SCP server.

By default, Net_SCP::put() does not read from the local filesystem. $data is dumped directly into $remote_file. So, for example, if you set $data to 'filename.ext' and then do Net_SCP::get(), you will get a file, twelve bytes long, containing 'filename.ext' as its contents.

Setting $mode to NET_SCP_LOCAL_FILE will change the above behavior. With NET_SCP_LOCAL_FILE, $remote_file will contain as many bytes as filename.ext does on your local filesystem. If your filename.ext is 1MB then that is how large $remote_file will be, as well.

Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take care of that, yourself.

Parameters

string $remote_file
string $data
int $mode
callable $callback

Return Value

bool

mixed get(string $remote_file, string $local_file = false)

Downloads a file from the SCP server.

Returns a string containing the contents of $remote_file if $local_file is left undefined or a boolean false if the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the operation

Parameters

string $remote_file
string $local_file

Return Value

mixed

_send(string $data)

Sends a packet to an SSH server

Parameters

string $data

string _receive()

Receives a packet from an SSH server

Return Value

string

_close()

Closes the connection to an SSH server