on 01/30/2001 11:46 PM, Nicholas G. Thornton at
[EMAIL PROTECTED] wrote:
> --- "Scott R. Godin" wrote:
> print $Net::FTP::VERSION;
> --- end of quote ---
> It's v 2.56 . I'm not quite sure how you mean I got it backwards. The code at
> present is something like . . .
ok you're about as current as you need to be, anyway.
> open(FH, '>temp'); # access the' temp' file
> print FH $foo; # write to 'temp'
> close FH;
>
> And I can't quite figure out how to get from that (writing to a local file) to
> writing to the file on the ftp server.
when you want to SEND a file
you don't open it as ">file" because that CLOBBERS the existing file...
you would probably want to open it as "<file" instead ;)
just by way of example, here's a script I use to download three files
generated via crontab at my ISP's shell account to my local machine.
print "Downloading ...\n";
use Net::FTP;
my $curdir = '~/public_html/cgi-scripts/ncrp/input_files/';
my $ftp = Net::FTP->new('216.155.0.50') or die ("Could not open
connection: $!");
$ftp->login($user, $pass) or die ("Could not log in! $!");
$ftp->ascii() or die ("could not change type to ascii! $!");
my @files = ( "${curdir}maps_list.txt",
"${curdir}ftpinfo.txt",
"${curdir}ftpdirs_full_backup.txt" );
$ftp->cwd($curdir) or die ("Could not change directory $!");
foreach my $file (@files) {
$ftp->get($file) or die ("Could not download $file! $!");
print "$file download successful!\n";
}
$ftp->quit() or die("error closing FTP session: $!");
Now, I see no reason why you NEED to open a filehandle in order to send a
file, when you could simply do something like:
use File::Spec 0.82;
my $file =
File::Spec->catfile( File::Spec->curdir(), 'testfile.txt');
and then later on
$ftp->ascii() or die ("could not change type to ascii!\n$!");
$ftp->put($file, 'newtestfile.txt') or die ("Could not upload $file!\n$!");
print "Successful\n";
$ftp->quit() or die("error closing FTP session:\n$!");
> --
> ~nikc
>
> [ http://www.phreelance.net/ ]
> [ [EMAIL PROTECTED] ]
> [EMAIL PROTECTED] is depricated
"deprecated"
--
Scott R. Godin | e-mail : [EMAIL PROTECTED]
Laughing Dragon Services | web : http://www.webdragon.net/