wfsp has asked for the wisdom of the Perl Monks concerning the following question:

FTPing a script.
From the doc:
The protocol also defines several standard translations which the file can undergo during transfer. These are ASCII, EBCDIC, binary, and byte. ASCII is the default type, and indicates that the sender of files will translate the ends of lines to a standard representation which the receiver will then translate back into their local representation.

When I ftp a script and run it I get 'page cannot be displayed'.
If I use my ftp prog it is ok. Is this a translation problem? I expected the 'ASCII is the default' to look after that.
If I need to set '$ftp->ascii' what 'ARGS' are needed.

#!/usr/bin/perl use strict; use warnings; use Net::FTP; my $host = 'xxxxx'; my $uid = 'xxxxx'; my $pwd = 'xxxxx'; my $local_file = 'c:/perl/myperl/dev/test_mod.cgi'; my $remote_path = 'docroot/z_cwi_cgi/z_test'; my $remote_file = 'test_mod.cgi'; my $ftp = Net::FTP->new( $host ) or die "can't connect"; $ftp->login( $uid, $pwd ) or die "can't login"; $ftp->cwd( $remote_path ) or die "can't cwd"; $ftp->ascii() or die "can't ascii"; $ftp->put( $local_file, $remote_file ) or die "can't put"; $ftp->quit or die "can't quit";
I use Net::FTP for posting html files and have found it excellent.
winXP and activestate 5.8
Updated: Added $ftp->ascii() after $ftp->cwd()
Update 2: This node has the answer 240895. Apologies for not looking harder.
Update 3: The workround in 240895 works! All praise to Thelonius!

Replies are listed 'Best First'.
Re: Net::FTP ascii translation
by Joost (Canon) on Jul 15, 2004 at 08:48 UTC
    If I need to set '$ftp->ascii' what 'ARGS' are needed.

    According to the docs none, ascii() has no arguments. You call $ftp->ascii() to set ASCII mode, and $ftp->binary() to set binary mode.

    Since you're ftp'ing a .cgi file, I'm assuming you need ASCII mode, and you need to make the script executable after transfering it. Mabe something like $ftp->site("chmod 755 $remote_file").

    I've hardly ever used Net::FTP, so I might be completely wrong.

      Mine says:
      ascii([ARGS])
      I can see that ARGS are optional but even with $ftp->ascii() added to the script I get the same result.