Net::FTP help needed

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: $ [at] \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
DFS [ Di, 16 Januar 2007 03:58 ] [ ID #1597876 ]

Re: Net::FTP help needed

On 2007-01-16, Al Moodie <nospam [at] nospam.com> wrote:
> use Net::FTP;
> $ftp = Net::FTP->new("ftp.host.com")
> or die "Can't connect: $ [at] \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
Peter Billam [ Di, 16 Januar 2007 04:28 ] [ ID #1597877 ]

Re: Net::FTP help needed

On 16 Jan 2007 14:28:30 +1100, Peter Billam
<peter [at] pjb.dpiwe.tas.gov.au> 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
DFS [ Di, 16 Januar 2007 23:07 ] [ ID #1597882 ]
Perl » comp.lang.perl.modules » Net::FTP help needed

Vorheriges Thema: Net::SFTP - setting binary mode on Windows
Nächstes Thema: CGI & LWP::UserAgent - forwarding cookies - how?