You want to get all the files in the current remote directory right?
Use the ls() method to get a list of all the files and then do individual get() calls for each file in the list. | [reply] |
Yeah, I thought about using ls, but apparently the files are hidden? Not sure why. If I do $ftp->get(/path/to/file) it gets it. But cwd'ing to the directory, and doing ls, returns a null list. :(
| [reply] |
| [reply] [d/l] [select] |
If I do $ftp->get(/path/to/file) it gets it. But cwd'ing to the directory, and doing ls, returns a null list.
I think this has nothing to do with Net::FTP or any sort of mget or ls function. It has to do with how permissions are set on the particular directory on the ftp server.
There's a little trick that the ftp maintainer can play with directory permissions, to provide a certain amount of "access control" or "data security" for files in the given directory. On a unix system, you can do this to a directory:
chmod 751 some_directory
which causes it to have permission (mode) flags like this:
"rwxr-x--x", which means:
- first "rwx": the owner can read (i.e. search), write (i.e. create/rename/delete files), and "execute" (i.e. access files) within the directory
- second "r-x": the group associated with the directory can read (search) and execute (access files)
- third "--x": everybody else, usually including the anonymous ftp user, can only access files -- but since they cannot search, they must know the exact name of each file they want to access.
So, this sort of permission allows the ftp server to provide some data protection -- that is, to limit distribution to specific recipients -- because only the owner can put files in, and the only people that can get files are those in the owner's group, or else people who have been told exactly what file names to retrieve.
This is also commonly used on ftp "upload" directories, where anon.ftp users can "put" files -- here the permission would be "rwxrwx-wx": anybody can create files in the directory, but only owner and group can search for file names. If one anon.ftp user puts a file into such a directory, other anon.ftp users won't know it's there, unless they are told what the file name is by someone who knows.
(updated to fix grammar) | [reply] [d/l] |
Probably not what you're hoping for, I admit, but I've had a great deal of success by using Perl to generate a script file that is in turn fed to the ftp executable.John | [reply] |
my @files = $ftp->ls();
foreach my $file(@files) {
$ftp->get($file)
or die "get failed", $ftp->message;
}
| [reply] [d/l] |