bdunbar has asked for the wisdom of the Perl Monks concerning the following question:
Learning PERL, needing a real-world example to hurl myself upon, I picked a problem I've already resolved using BASH.
What I need: Login to an FTP server. Using a list of directories, move all files in that directory tree to another directory, renaming to standard.
So this
/test1/in/foo.edi /test1/in/dir/bar.edi
becomes this
/composite/test1_YYYYMMDDHHSS_foo.edi /composite/test1_YYYYMMDDHHSS_bar.edi
I've got the move and rename down. For 'a' directory.
Where I appear to be stuck is getting that sucker to walk the directory tree.
It's executing without error, I just don't see where I've gone wrong, why it's not calling wanted subroutine.
Script#!/usr/bin/perl -s use strict; use warnings; use diagnostics; use Net::FTP::Find; my($host) = "ftp2.site.com"; my($user) = "redacted"; my($password) = "redacted"; my($ftpdir) = "/test1/in"; my $ftpfind = Net::FTP::Find->new($host) or die "Can't open $host: $@\ +n"; $ftpfind->login($user, $password) or die "Can't log $user in: $ftpfind +\n"; $ftpfind->cwd($ftpdir) or die "Can't cwd to $ftpdir: $ftpfind\n"; print "this is ftpfind $ftpfind\n"; # sanity check so I know it's doin +g _something_ $ftpfind->finddepth (\&wanted, "/test1/in"); sub wanted { print "hello"; print $_; }
edited to add shell type and variable $ftpdir. Thanks, dulwar.$ ./dirwalkftp.pl this is ftpfind Net::FTP::Find=GLOB(0x10083ce10) $
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Walking a directory tree with net:FTP:find
by thundergnat (Deacon) on May 31, 2012 at 17:06 UTC | |
by bdunbar (Initiate) on May 31, 2012 at 19:08 UTC | |
by bdunbar (Initiate) on May 31, 2012 at 20:38 UTC | |
by thundergnat (Deacon) on Jun 01, 2012 at 14:04 UTC | |
|
Re: Walking a directory tree with net:FTP:find
by dulwar (Monk) on May 31, 2012 at 17:11 UTC | |
by bdunbar (Initiate) on May 31, 2012 at 19:12 UTC |