Sui Ming Louie wrote:
> According to perldoc Net::FTP, the method $ftp->ascii has arguments. I
> tried putting a 1 as the argument. It appears the files that are still
> being transferred in binary mode. I am running Windoze XP and Perl
> v5.8.0 build 804. The options I am using are
>
>
>
> –aIPADDR
>
> -uusername
>
> -ppassword
>
> -ddefault_remote_directory
>
> -t (text or ascii mode)
>
> -h (display hash)
>
>
>
> The remote machine is an SGI workstation. Any assistance will be
> greatly appreciated.
>
>
>
> Abridged perl code follows:
>
>
>
> use Net::FTP;
>
> use Getopt::Std;
>
> getopts ('a:u:p:d:th', \%opts);
>
>
>
> my $default_dir = "/xxxx/Project"; # changed for this posting
>
>
>
> # ====================
>
> # default IP address: changed for this posting
>
> # ====================
>
> $opts{'a'} = "xxx.yyy.zzz.41" if (not defined $opts{'a'});
>
>
>
> # =======================================================
>
> # append default directory if only base directory given
>
> # =======================================================
>
> $opts{'d'} = $default_dir if (not defined $opts{'d'});
>
> $opts{'d'} = $default_dir . '/' . $opts{'d'} if (not ($opts{'d'} =~ /^\//));
>
>
>
> my $ftp = Net::FTP->new ($opts{'a'}, Debug => 0);
>
> $ftp->login ("tensyl", "xxxxxx"); # changed for this posting
>
> $ftp->cwd ($opts{'d'});
>
>
>
> # ======================
>
> # ascii (or text) mode
>
> # ======================
>
> $ftp->ascii(1) if (defined $opts{'t'});
This should be sufficient:
$ftp->ascii if defined $opts{'t'};
>
>
> my $getrv;
>
> while (defined $ARGV[0]) {
>
> $getrv = $ftp->get ($ARGV[0]);
>
> if (defined $getrv) {
>
> print "$getrv\n";
>
> } else {
>
> print ("Error in getting file: <$default_dir/$ARGV[0]>\n");
>
> } # if
>
>
>
> shift @ARGV;
>
> } # while
>
>
>
> $ftp->quit;
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs