Net::FTP help needed

Net::FTP help needed

am 16.01.2007 03:58:32 von DFS

Hi,

I've got Net::FTP working uploading a .txt file.

use Net::FTP;
$ftp = Net::FTP->new("ftp.host.com")
or die "Can't connect: $@\n";

$ftp->login($username, $password)
or die "Couldn't authenticate, even with username and password. \n";

$ftp->put($localfile)
or die "Can't send $localfile: $!\n";

$ftp->quit;

How do I get it to upload a binary file, I don't follow the
documentation. Somewhere in the script I believe I have to put:

type => "binary" Where?

Al Modie

Re: Net::FTP help needed

am 16.01.2007 04:28:30 von Peter Billam

On 2007-01-16, Al Moodie wrote:
> use Net::FTP;
> $ftp = Net::FTP->new("ftp.host.com")
> or die "Can't connect: $@\n";
> $ftp->login($username, $password)
> or die "Couldn't authenticate, even with username and password. \n";
> $ftp->put($localfile)
> or die "Can't send $localfile: $!\n";
> $ftp->quit;
>
> How do I get it to upload a binary file, I don't follow the
> documentation. Somewhere in the script I believe I have to put:
> type => "binary" Where?
>
According to "perldoc Net::FTP", binary is a method, just like
login, put and quit are. That should mean something like:

$ftp->login($username, $password)
or die "Couldn't authenticate, even with username and password.\n";
$ftp->binary()
or die "Can't switch to binary mode: $!\n";
$ftp->put($localfile)
or die "Can't send $localfile: $!\n";

Hope this helps, Regards, Peter

--
AUS/TAS/DPIW/CIT/Servers hbt/lnd/l8 6233 3061 http://www.pjb.com.au
Pasaré, pasarémos dice el agua y canta la verdad contra la piedra
-- Pablo Neruda

Re: Net::FTP help needed

am 16.01.2007 23:07:44 von DFS

On 16 Jan 2007 14:28:30 +1100, Peter Billam
wrote:


>According to "perldoc Net::FTP", binary is a method, just like
>login, put and quit are. That should mean something like:
>
>$ftp->login($username, $password)
> or die "Couldn't authenticate, even with username and password.\n";
>$ftp->binary()
> or die "Can't switch to binary mode: $!\n";
>$ftp->put($localfile)
> or die "Can't send $localfile: $!\n";
>
>Hope this helps, Regards, Peter

It's simple, it works. I guess I do not have a good understanding of
module use. Thank you.
Al Moodie