pglinx has asked for the wisdom of the Perl Monks concerning the following question:

I have been able to put but can't seem to get Mabey it is not as simple a just reversing the process but I can't seem to find much info on it out there..

#!/usr/local/bin/perl5 require 'ftplib.pl'; $FtpHost = "panix.com"; if (&ftp::open($FtpHost) != 1) { die "can't open $FtpHost\n"; } if (&ftp::cwd(pub) != 2) { die "Can't change directories\n"; } if (&ftp::cwd(gizmo) != 2) { die "Can't change directories\n"; } @dirList = ftp::list(); foreach (@dirList) { print("\t$_\n"); } $file = 'ninpaths.txt'; if (&ftp::get($file) != 1) { die "cannot get $file\n"; } &ftp::close;

20060512 Janitored by Corion: Exchanged PRE for CODE tag

Replies are listed 'Best First'.
Re: ftp get
by nimdokk (Vicar) on May 11, 2006 at 17:53 UTC
    Have you tried using Net::FTP?
Re: ftp get
by CountOrlok (Friar) on May 11, 2006 at 17:54 UTC
    What error do you get when you use ftp::get()?
    By the way, which version of ftplib.pl are you using?
    You may want to consider using Net::FTP instead.

    -imran

      cannot get ninpaths.tx version 1.1 I'll research Net::FTP
        Version 1.1? That's like from 1995 or something!!
        Looking at your syntax, it seems you are getting guidance from a Perl 4 book. Although the syntax still works, I'd recommend finding a guide that teaches Perl 5.6 or greater (unless you are supporting systems that use older versions of Perl).
        After your get() fails, what does Ftp::error() return?
        The version of ftplib.pl I found through google (version 1.1L) does not declare the $Error variable as a global. Not sure why.
        -imran
Re: ftp get
by moklevat (Priest) on May 11, 2006 at 18:26 UTC
    I just checked the Monastery's Pedantry Roster and it looks like it is my turn to point out that it is good practice to

    use strict; use warnings;
    with your script.