in reply to Perl FTP troubles
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl FTP troubles
by LClarke (Initiate) on Apr 16, 2016 at 10:44 UTC | |
by marto (Cardinal) on Apr 16, 2016 at 10:58 UTC | |
by LClarke (Initiate) on Apr 16, 2016 at 19:02 UTC | |
by marto (Cardinal) on Apr 18, 2016 at 10:00 UTC |