Speedfreak has asked for the wisdom of the Perl Monks concerning the following question:
Hey all,
So I'm using NET::Ftp to transfer files on demand from a remote server. However, despite all the checks for valid characters in filenames, I cant by the nature of the beast stop users giving my script filenames to retrieve that dont exist.
What I need to do is attempt to grab a file but trap if the server gives me a "file not found" error.
I thought about just checking if the file exists after the transfer has taken place - thus proving whether or not it was downloaded but that seems rather inelegant to me.
Anyone know how to check for errors with NET::Ftp? Perldoc doesn't seem to mention anything.
The code I'm using to grab the file is thus.
sub fetch_metar {
$ftp = Net::FTP->new($hostname);
$ftp->login("anonymous","metar\@speedfreak.com");
$ftp->get($path.$station.".TXT", $datapath.$station.".TXT");
$ftp->quit;
}
- Jed
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trapping errors from NET::Ftp
by chromatic (Archbishop) on Mar 29, 2000 at 20:59 UTC | |
by Anonymous Monk on May 23, 2000 at 02:21 UTC | |
by neshura (Chaplain) on May 23, 2000 at 02:35 UTC | |
by reptile (Monk) on May 23, 2000 at 02:35 UTC | |
by WintersMystic (Novice) on Oct 25, 2001 at 08:34 UTC | |
|
Re: Trapping errors from NET::Ftp
by lhoward (Vicar) on Mar 29, 2000 at 22:35 UTC | |
|
RE: Trapping errors from NET::Ftp
by Anonymous Monk on Mar 30, 2000 at 05:16 UTC |