Find out why it failed:
$ftp->get("$station_name.TXT", "../area/weather/$station_name.TXT") or die "failed to retrieve file $station_name.TXT - $ftp->message";
Consider turning on debugging:
my $ftp = Net::FTP->new("tgftp.nws.noaa.gov", DEBUG => 1);
Update: here's a basic working example:
#!/usr/bin/perl use strict; use warnings; use Net::FTP; # Log into the ftp # my $station_name = 'EGLL.TXT'; my $ftp = Net::FTP->new("tgftp.nws.noaa.gov", DEBUG => 1); $ftp->login("anonymous", "anonymous") or die "login error - " , $ftp->message; $ftp->cwd("data/observations/metar/stations") or die "cwd failed - ", $ftp->message; $ftp->ascii; # N.B. I changed the destination path here: $ftp->get("$station_name", "d:\\junk\\$station_name") or die "failed to retrieve file $station_name - ", $ftp->message; $ftp->quit; # End ftp session #
Update: fixed typo
In reply to Re: Perl FTP troubles
by marto
in thread Perl FTP troubles
by LClarke
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |