The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::FTPSSL - A FTP over SSL/TLS class

VERSION 0.06

SYNOPSIS

  use Net::FTPSSL;

  my $ftps = Net::FTPSSL->new('ftp.yoursecureserver.com', 
                              Port => 21,
                              Encryption => 'E',
                              Debug => 1) 
    or die "Can't open ftp.yoursecureserver.com";

  $ftps->login('anonymous', 'user@localhost') 
    or die "Can't login: ", $ftps->last_message();

  $ftps->cwd("/pub") or die "Can't change directory: " . $ftps->last_message;

  $ftps->get("file") or die "Can't get file: " . $ftps->last_message;

  $ftps->quit();

DESCRIPTION

Net::FTPSSL is a class implementing a simple FTP client over a Secure Shell Layer (SSL) connection written in Perl as described in RFC959 and RFC2228.

CONSTRUCTOR

new ( HOST [, OPTIONS ])

Creates a new Net::FTPSSL object and opens a connection with the HOST. HOST is the address of the FTP server and it's a required argument. OPTIONS are passed in a hash like fashion, using key and value pairs.

OPTIONS are:

Port - The port number to connect to on the remote FTP server. Default value is 21 for EXP_CRYPT or 990 for IMP_CRYPT.

Encryption - The connection can be implicitly (IMP_CRYPT) or explicitly (EXP_CRYPT) encrypted. In explicit cases the connection begins clear and became encrypted after an "AUTH" command is sent. Default value is EXP_CRYPT.

DataProtLevel - The level of security on the data channel. Default is P, where everything is encrypted. C is clear, and mixed are S and E.

useSSL - Use this option to connect to the server using SSL instead of TLS. TLS is the default encryption type and the more secure of the two protocalls. Set useSSL = 1> to use SSL.

Timeout - Set a connection timeout value. Default value is 120.

Buffer - This is the block size that Net::FTPSSL will use when a transfer is made. Default value is 10240.

Debug - This set the debug informations option on/off. Default is off.

Trace - Turns on/off put/get download tracing to STDERR. Default is off.

METHODS

Most of the methods return true or false, true when the operation was a succes and false when failed. Methods like list or nlst return an empty array when fail.

login(USER, PASSWORD)

Use the given informations to log into the FTP server.

list([DIRECTORY])

This method returns a list of files in this format:

 total 5
 drwxrwx--- 1 owner group          512 May 31 11:16 .
 drwxrwx--- 1 owner group          512 May 31 11:16 ..
 drwxrwx--- 1 owner group          512 Oct 27  2004 foo
 drwxrwx--- 1 owner group          512 Oct 27  2004 pub
 drwxrwx--- 1 owner group          512 Mar 29 12:09 bar

If DIRECTORY is omitted, the method will return the list of the current directory.

nlst([DIRECTORY])

Same as list but returns the list in this format:

 foo
 pub
 bar

Personally, I suggest to use list instead of nlst.

ascii

Sets the transfer file in ASCII mode.

binary

Sets the transfer file in binary mode. No transformation will be done.

get(REMOTE_FILE, [LOCAL_FILE])

Retrives the REMOTE_FILE from the ftp server. LOCAL_FILE may be a filename or a filehandle. Return undef if it fails.

put(LOCAL_FILE, [REMOTE_FILE])

Stores the LOCAL_FILE into the remote ftp server. LOCAL_FILE may be filehandle, but in this case REMOTE_FILE is required. Return undef if it fails.

uput(LOCAL_FILE, [REMOTE_FILE])

Stores the LOCAL_FILE into the remote ftp server. LOCAL_FILE may be filehandle, but in this case REMOTE_FILE is required. If REMOTE_FILE already exists, a unique name is calculated from it. Return undef if it fails.

delete(REMOTE_FILE)

Deletes the indicated REMOTE_FILE.

cwd(DIR)

Attempts to change directory to the directory given in DIR.

pwd

Returns the full pathname of the current directory.

cdup

Changs directory to the parent of the current directory.

mkdir(DIR)

Creates the indicated directory. No recursion at the moment.

rmdir(DIR)

Removes the empty indicated directory. No recursion at the moment.

noop

It specifies no action other than the server send an OK reply.

site(ARGS)

Send a SITE command to the remote server and wait for a response.

supported(CMD [,SITE_OPT])

Returns TRUE if the remote server supports the given command. CMD must match exactly. If the CMD is SITE and SITE_OPT is supplied, it will also check if the specified SITE_OPT sub-command is supported.

quot(CMD [,ARGS])

Send a command, that Net::FTPSSL does not directly support, to the remote server and wait for a response.

Returns the most significant digit of the response code.

WARNING This call should only be used on commands that do not require data connections. Misuse of this method can hang the connection if the internal list of FTP commands using a data channel is incomplete.

last_message() or message()

Use either one to collect the last response from the FTP server. This is the same response printed to STDERR when trace is turned on.

AUTHOR

Marco Dalla Stella - <kral at paranoici dot org>

MAINTAINER

Curtis Leach - As of v0.05

SEE ALSO

Net::Cmd

Net::FTP

Net::SSLeay::Handle

IO::Socket::SSL

RFC 959 - ftp://ftp.rfc-editor.org/in-notes/rfc959.txt

RFC 2228 - ftp://ftp.rfc-editor.org/in-notes/rfc2228.txt

RFC 4217 - ftp://ftp.rfc-editor.org/in-notes/rfc4217.txt

CREDITS

Graham Barr <gbarr at pobox dot com> - for have written such a great collection of modules (libnet).

BUGS

I'm currently testing the module with proftpd and Titan FTP. I'm having a lot of trouble with the second at the moment. Put or get phases seem to work ok (sysread and syswrite don't return any errors) but the server doesn't receive all the sent data. I'm working on it.

COPYRIGHT

Copyright (c) 2005 Marco Dalla Stella. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.