Click to See Complete Forum and Search --> : encode file to UTF-8 and ftp


ccc
06-25-2004, 05:07 PM
hi

I've written a perl script to encode the file to UTF-8 and ftp , but it wont send any files.

I get following error message:
550 /var/data.txt: The system cannot find the path specified.

knows someone howto correct this code ?


#!/usr/bin/perl -w

use strict;
use warnings;

use Net::FTP;
use Net::Netrc;

use Encode qw/encode decode/;
use utf8;

my $server = "IP_address";
my $user = "ftpuser";
my $password = "pass";
my $file = "/var/data.txt";

my $ftp = Net::FTP->new ($server, Timeout => 9000, Debug => 3);
$ftp or die "$server: cannot connect: $@";
$ftp->login ($user,$password) or die "$_: Could not login: " . $ftp->message;
$ftp->cwd($destination);

#encoding and put file
open FILE, '<', $file or die "open $file $!";
binmode FILE, 'encoding(utf-8)' or die $!;

$ftp->put(\*FILE, $file); # must give remote name.

$ftp->quit;

Jeff Mott
06-30-2004, 04:35 PM
Err, I think the only suggestion I can give you is to double check the path. Note that some Web server configurations prevent any CGI script from accessing files above the directory assigned to you by the server.