NAME

Net::SCP - Perl extension for secure copy protocol

SYNOPSIS

#procedural interface
use Net::SCP qw(scp iscp);
scp($source, $destination);
iscp($source, $destination); #shows command, asks for confirmation, and
                             #allows user to type a password on tty

#OO interface
$scp = Net::SCP->new( "hostname", "username" );
#with named params
$scp = Net::SCP->new( { "host"=>$hostname, "user"=>$username } );
$scp->get("filename") or die $scp->{errstr};
$scp->put("filename") or die $scp->{errstr};
#tmtowtdi
$scp = new Net::SCP;
$scp->scp($source, $destination);

#Net::FTP-style
$scp = Net::SCP->new("hostname");
$scp->login("user");
$scp->cwd("/dir");
$scp->size("file");
$scp->get("file");
$scp->quit;

DESCRIPTION

Simple wrappers around ssh and scp commands.

SUBROUTINES

scp SOURCE, DESTINATION

Can be called either as a subroutine or a method; however, the subroutine interface is depriciated.

Calls scp in batch mode, with the -B -p -q and -r options. Returns false upon error, with a text error message accessable in $scp->{errstr}.

Returns false and sets the errstr attribute if there is an error.

iscp SOURCE, DESTINATION

Can be called either as a subroutine or a method; however, the subroutine interface is depriciated.

Prints the scp command to be execute, waits for the user to confirm, and (optionally) executes scp, with the -p and -r flags.

Returns false and sets the errstr attribute if there is an error.

METHODS

new HOSTNAME [ USER ] | HASHREF

This is the constructor for a new Net::SCP object. You must specify a hostname, and may optionally provide a user. Alternatively, you may pass a hashref of named params, with the following keys:

host - hostname
user - username
interactive - bool
cwd - current working directory on remote server
login [USER]

Compatibility method. Optionally sets the user.

cwd CWD

Sets the cwd (used for a subsequent get or put request without a full pathname).

get REMOTE_FILE [, LOCAL_FILE]

Uses scp to transfer REMOTE_FILE from the remote host. If a local filename is omitted, uses the basename of the remote file.

size FILE

Returns the size in bytes for the given file as stored on the remote server. Returns 0 on error, and sets the errstr attribute. In the case of an actual zero-length file on the remote server, the special value '0e0' is returned, which evaluates to zero when used as a number, but is true.

(Implementation note: An ssh connection is established to the remote machine and wc is used to determine the file size.)

put LOCAL_FILE [, REMOTE_FILE]

Uses scp to trasnfer LOCAL_FILE to the remote host. If a remote filename is omitted, uses the basename of the local file.

binary

Compatibility method: does nothing; returns true.

AUTHORS

Ivan Kohler <ivan-netscp_pod@420.am> Anthony Deaver <bishop@projectmagnus.org>

Thanks to Jon Gunnip <jon@soundbite.com> for fixing a bug with size().

BUGS

Still has no-OO cruft.

In order to work around some problems with commercial SSH2, if the source file is on the local system, and is not a directory, the -r flag is omitted.

It's probably better just to use SSH1 or OpenSSH <http://www.openssh.com/>

The Net::FTP-style OO stuff is kinda lame. And incomplete.

SEE ALSO

scp(1), ssh(1)