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

    Progress! It's at least a little different, now.

    Error:

    failed to retrieve file EGLL.TXT - Permission denied.

    In your working example, were you able to get the file? I copypasted it, and only changed the destination path.

      Yes:

      D:\junk>type EGLL.TXT 2016/04/16 10:20 EGLL 161020Z AUTO 34008KT 300V040 9999 -RA BKN011/// OVC023/// //////T +CU 06/02 Q 1004 TEMPO RA

      Do you have appropriate permissions to create a file in the target path? I've also tested the following successfully:

      $ftp->get("$station_name", "..\\$station_name") or die "failed to retrieve file $station_name - ", $ftp->message;

        ...You nailed it. The script file didn't have write permissions.

        Thank you!