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

Hello Everyone I would greatly appreciate insight on why I can't seem to get the following to work,

chdir($nas_location); #change the local directory $ftp=Net::FTP::Recursive->new('172.20.1.36:9921',Timeout=>10,Debug=>1) + or die getftploginpass(); my $LOGIN = $hashlogin{"LOGIN"}; my $PASSWORD = $hashlogin{"PASSWORD"}; $ftp->login($LOGIN,$PASSWORD) or $error=1; $ftp->cwd("$remote_path") or $error=1; $ftp->binary(); my @list = $ftp->ls(); my $output = $ftp->rget( map{($_, 1)} $extract); $ftp->quit; print "Got \$output of:\n$output\n";


With the debug on, the ftp client shows successful cd to the local directory.
$ftp->cwd is working as the client shows cwd successfull.
The $extract is a directory tree insight the remote path. Once the rget hits it is not creating the local directory structures. The ftp client comes back with a pwd command.
Where am I going wrong?
The Id I am running the script has full read / write access to the local directory. I can create the directory manually.
Am I missing the point?

Replies are listed 'Best First'.
Re: NET::FTP::Recursive
by kwaping (Priest) on Jan 24, 2006 at 16:05 UTC
    The syntax you're using for rget doesn't look anything like what the Net::FTP::Recursive docs describe. What are you trying to accomplish there?

    Also, what is $extract? It's not defined elsewhere in your posted code snippet.
      kwaping is right. from the CPAN docs:
      rget ( [ParseSub =>\&yoursub] [,FlattenTree => 1] [,RemoveRemoteFiles +=> 1] )
      If you want the map() to be used in parsing, i believe you need to pass it as a subroutine reference.

      __________
      Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
      - Terry Pratchett

        So if I try the following ( $yesterdays_date(variable) being a directory inside the remote_path) is correct? I don't wish to remove the files just copy...
        my $output = $ftp->rget([ParseSub =>\&$yesterdays_date]);
        I think what I am confused about is the \&yoursub call. Do I replace this sytex with my reference to the directory?
      Hello Sorry, the snippet it did not include all the variables. The $extract variable is a directory inside the remote_path i.e
      /tng/logs/KM - > The KM being the $extract. The idea is to throw a different directory through a subroutine...
      The objective here is to simply login to the ftp site and copy a specific directory tree to a local storage network.
      The snippet was copied from the authors examples..
      Thank you for your time... your help is greatly appreciated.