NAME

Net::SCP::Expect - Wrapper for scp that allows passwords via Expect.

SYNOPSIS

Example 1 - uses login method, longhand scp:

my $scpe = Net::SCP::Expect->new;

$scpe->login('user name', 'password');

$scpe->scp('file','host:/some/dir');

.

Example 2 - uses constructor, shorthand scp:

my $scpe = Net::SCP::Expect->new(host=>'host', user=>'user', password=>'xxxx');

$scpe->scp('file','/some/dir'); # 'file' copied to 'host' at '/some/dir'

.

Example 3 - Copying from remote machine to local host

my $scpe = Net::SCP::Expect->new(user=>'user',password=>'xxxx');

$scpe->scp('host:/some/dir/filename','newfilename');

See the scp() method for more information on valid syntax.

PREREQUISITES

Expect 1.14. May work with earlier versions, but was tested with 1.14 (and now 1.15) only.

DESCRIPTION

This module is simply a wrapper around the scp call. The primary difference between this module and Net::SCP is that you may send a password programmatically, instead of being forced to deal with interactive sessions.

USAGE

Net::SCP::Expect->new(option=>val,...)

Creates a new object and optionally takes a series of options (see OPTIONS below).

host(host)

Sets the host for the current object

login(login,password)

If the login and password are not passed as options to the constructor, they must be passed with this method (or set individually - see 'user' and 'password' methods). If they were already set, this method will overwrite them with the new values.

password(password)

Sets the password for the current user

user(user)

Sets the user for the current object

scp()

Copies the file from source to destination. If no host is specified, you will be using 'scp' as an expensive form of 'cp'.

There are several valid ways to use this method

REMOTE TO LOCAL

scp(source, user@host:destination);

scp(source, host:destination); # User already defined

scp(source, :destination); # User and host already defined

scp(source, destination); # Same as previous

LOCAL TO REMOTE

scp(user@host:source, destination);

scp(host:source, destination);

scp(:source, destination);

OPTIONS

cipher - Selects the cipher to use for encrypting the data transfer.

host - Specify the host name. This is now useful for both local-to-remote and remote-to-local transfers.

password - The password for the given login.

port - Use the specified port.

preserve - Preserves modification times, access times, and modes from the original file.

recursive - Set to 1 if you want to recursively copy entire directories.

timeout - Sets the timeout value for your operation. The default is 10 seconds.

user - The login name you wish to use.

verbose - Set to 1 if you want verbose output sent to STDOUT.

NOTES

The -q option (disable progress meter) is automatically passed to scp.

The -B option may NOT be set. If you don't want to send passwords, I recommend using Net::SCP instead.

In the event that Ben Trott releases a version of Net::SSH::Perl that supports scp, I recommend using that instead.

Don't whine to me about putting passwords in scripts. Set your permissions appropriately or use a .rc file of some kind.

FUTURE PLANS

There are a few options I haven't implemented. If you *really* want to see them added, let me know and I'll see what I can do.

A test suite (yes, I almost have one together)

KNOWN BUGS

At least one user has reported warnings related to POD parsing with Perl 5.00503. These can be safely ignored. They do not appear in Perl 5.6 or later.

THANKS

Thanks to Roland Giersig (and Austin Schutz) for the Expect module. Very handy.

AUTHOR

Daniel Berger

djberg96@hotmail.com