Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Net::FTP::Recursive code not downloading files

by wazat (Scribe)
on Dec 12, 2013 at 20:39 UTC ( #1066915=note: print w/ replies, xml ) Need Help??


in reply to Net::FTP::Recursive code not downloading files

I suspect your problem is your GetFiles() sub. From what I understand from the module docs, the ParseSub argument is meant to provide an alternative parser for directory listing output. Since you are not parsing the directory listing output then DO NOT include the ParseSub argument.

I see a commented out line specifying MatchFiles.

$ftp->rget( FlattenTree => 1, MatchFiles => qr/\.txt/, );

What happens when you use this?

Also, that pattern would be more correct if you anchor the the end of the file name.

MatchFiles => qr/\.txt$/,


Comment on Re: Net::FTP::Recursive code not downloading files
Select or Download Code
Re^2: Net::FTP::Recursive code not downloading files
by bowei_99 (Friar) on Dec 12, 2013 at 22:02 UTC
    Thanks. If I replace the rget call with this:
    $ftp->rget( FlattenTree => 1, MatchDirs => qr/PowerEdge (R810|R610|R720|R620 +|M620|M1000E)/, MatchFiles => qr/\.txt$/, );
    I get it downloading directories, but it doesn't seem to find any text files, as it doesn't look like it's recursing deep enough. Is there a setting for how deep to go? I get this (snippet shown):
    Net::FTP::Recursive=GLOB(0x2355f08)>>> LIST Net::FTP::Recursive=GLOB(0x2355f08)<<< 150 Opening BINARY mode data co +nnection. Net::FTP::Recursive=GLOB(0x2355f08)<<< 226 Transfer complete. drwxrwxrwx 1 owner group 0 Aug 29 2012 Chassis Sys +tem Management drwxrwxrwx 1 owner group 0 Aug 29 2012 Diagnostics -rwxrwxrwx 1 owner group 144462 Aug 29 2012 index.html drwxrwxrwx 1 owner group 0 Sep 25 2012 Legacy drwxrwxrwx 1 owner group 0 Aug 29 2012 Network drwxrwxrwx 1 owner group 0 Aug 29 2012 Rack Soluti +ons drwxrwxrwx 1 owner group 0 Aug 29 2012 SAS Drive drwxrwxrwx 1 owner group 0 Aug 29 2012 SCSI non-RA +ID drwxrwxrwx 1 owner group 0 Aug 29 2012 Serial ATA drwxrwxrwx 1 owner group 0 Aug 29 2012 Systems Man +agement drwxrwxrwx 1 owner group 0 Aug 29 2012 Tape Automa +tion drwxrwxrwx 1 owner group 0 Aug 29 2012 Tape Drives Net::FTP::Recursive=GLOB(0x2355f08)>>> PWD Net::FTP::Recursive=GLOB(0x2355f08)<<< 257 "/Browse_For_Drivers/Server +s, Storage & Networking/PowerEdge/PowerEdge M1000E" is current direct +ory. Returned from rget in /Browse_For_Drivers/Servers, Storage & Networkin +g/PowerEdge. Net::FTP::Recursive=GLOB(0x2355f08)>>> CDUP Net::FTP::Recursive=GLOB(0x2355f08)<<< 250 CDUP command successful. Net::FTP::Recursive=GLOB(0x2355f08)>>> CWD PowerEdge M620 Net::FTP::Recursive=GLOB(0x2355f08)<<< 250 CWD command successful. Calling rget in /Browse_For_Drivers/Servers, Storage & Networking/Powe +rEdge Net::FTP::Recursive=GLOB(0x2355f08)>>> PASV Net::FTP::Recursive=GLOB(0x2355f08)<<< 227 Entering Passive Mode (143, +166,135,12,247,80) Net::FTP::Recursive=GLOB(0x2355f08)>>> LIST Net::FTP::Recursive=GLOB(0x2355f08)<<< 150 Opening BINARY mode data co +nnection. Net::FTP::Recursive=GLOB(0x2355f08)<<< 226 Transfer complete. drwxrwxrwx 1 owner group 0 Aug 29 2012 Application drwxrwxrwx 1 owner group 0 Aug 29 2012 BIOS drwxrwxrwx 1 owner group 0 Aug 29 2012 Chipset drwxrwxrwx 1 owner group 0 Aug 29 2012 Diagnostics drwxrwxrwx 1 owner group 0 Aug 29 2012 Drivers for + OS Deployment drwxrwxrwx 1 owner group 0 Aug 29 2012 Enterprise +Solutions drwxrwxrwx 1 owner group 0 Aug 29 2012 ESM drwxrwxrwx 1 owner group 0 Aug 29 2012 Fibre Chann +el drwxrwxrwx 1 owner group 0 Aug 29 2012 Firmware -rwxrwxrwx 1 owner group 147115 Aug 29 2012 index.html drwxrwxrwx 1 owner group 0 Aug 29 2012 Lifecycle C +ontroller drwxrwxrwx 1 owner group 0 Aug 29 2012 Network drwxrwxrwx 1 owner group 0 Sep 25 2012 PCIe SSS drwxrwxrwx 1 owner group 0 Aug 29 2012 SAS Drive drwxrwxrwx 1 owner group 0 Aug 29 2012 SAS RAID drwxrwxrwx 1 owner group 0 Aug 29 2012 SCSI non-RA +ID drwxrwxrwx 1 owner group 0 Aug 29 2012 Serial ATA drwxrwxrwx 1 owner group 0 Aug 29 2012 Systems Man +agement drwxrwxrwx 1 owner group 0 Aug 29 2012 Video Net::FTP::Recursive=GLOB(0x2355f08)>>> PWD Net::FTP::Recursive=GLOB(0x2355f08)<<< 257 "/Browse_For_Drivers/Server +s, Storage & Networking/PowerEdge/PowerEdge M620" is current director +y. Returned from rget in /Browse_For_Drivers/Servers, Storage & Networkin +g/PowerEdge. Net::FTP::Recursive=GLOB(0x2355f08)>>> CDUP Net::FTP::Recursive=GLOB(0x2355f08)<<< 250 CDUP command successful. Net::FTP::Recursive=GLOB(0x2355f08)>>> CWD PowerEdge R610

    -- Burvil

      I suspect your MatchDirs may be preventing the recursion. If the matching doesn't use the full path then the subdirectory names won't include the parent directory names.

      MatchDirs => qr/PowerEdge R810|R610|R720|R620|M620|M1000E)/,

      If that is the case, then you need to run your code on these 6 directories separately.

        Why would I need to run the code for each directory separately? Isn't that the whole point of recursion, so it will drill down into each directory until there are no more levels? The thing is, I don't know where the text files will be within the directory structure, so I have to traverse every directory and subdirectory.

        Also, on point about the regex. I tried changing it to the following:

        MatchDirs => qr/.*PowerEdge (R810|R610|R720|R620|M620|M1000E).*/,
        but I get the same thing.

        -- Burvil

      As wazat points out the problem is with MatchDirs, though not with path names, as you can see from the output that it is entering the directories you have in MatchDirs. Once it gets in to one of those directories though, it won't go any further because subsequent directories are not in MatchDirs - it checks every directory for a match before recursing, not just the top level.

      The solution is to get rid of the MatchDirs and call your code for each directory, setting the path in $params{dir}.
      e.g. dir => "Browse_For_Drivers/Servers, Storage & Networking/PowerEdge/PowerEdge R810"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1066915]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-11-27 22:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (188 votes), past polls