Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
7.4k views
in Java FTP by
Hello,

can anyone tell me, how I can include hidden files in dirDetails() listings from unix system?

It seems that files starting with a dot (.<filename>) are not included in the FTPFile field which is returned by the dirDetails() method. Is there any proceeding which would change this behavior? (the current ftp server i am using is running on an unix system)

thank you,
Chris

5 Answers

0 votes
by (162k points)
Log on to the FTP server via the command line FTP client, and experiment with the 'dir' command. You will only be able to see hidden files if the FTP server sends them as part of the listing.

Hello,

can anyone tell me, how I can include hidden files in dirDetails() listings from unix system?

It seems that files starting with a dot (.<filename>) are not included in the FTPFile field which is returned by the dirDetails() method. Is there any proceeding which would change this behavior? (the current ftp server i am using is running on an unix system)

thank you,
Chris
0 votes
by
Okay, I logged in via commandline with the following results:

When I call 'dir' I do not get the hidden files, and executing 'ls -la' gives me the hidden files.

So how can I make the java ftpclient call the 'ls -la' command?

Thanks
Chris
0 votes
by (162k points)
Ok, now type 'debug' before 'ls -la' - this will allow you see what is being sent to the FTP server.

On my current machine this gives me:

ftp> ls -al
---> PORT 10,0,0,2,16,12
200 PORT command successful.
---> NLST -al

which is very interesting - it looks like some FTP servers allow the directory parameter to be an argument for 'ls' .

What does your server return?


Okay, I logged in via commandline with the following results:

When I call 'dir' I do not get the hidden files, and executing 'ls -la' gives me the hidden files.

So how can I make the java ftpclient call the 'ls -la' command?

Thanks
Chris
0 votes
by
Ok, now type 'debug' before 'ls -la' - this will allow you see what is being sent to the FTP server.

On my current machine this gives me:

ftp> ls -al
---> PORT 10,0,0,2,16,12
200 PORT command successful.
---> NLST -al

which is very interesting - it looks like some FTP servers allow the directory parameter to be an argument for 'ls' .

What does your server return?


My server returns something very similar. I got the following output:

ftp> debug
Debugging EIN .
ftp> ls -la
---> PORT 192,168,0,41,5,131
200 PORT command successful.
---> NLST -la

Chris
0 votes
by (162k points)
One possible hack that might do it is below. This is uncompiled, you might need to play around with it a little.

ftpc.chdir();  //into the directory you are after
String[] listing = ftpc.dir("-ls",  true);
UnixFileParser parser = new UnixFileParser(); // or WindowsFileParser
FTPFile[] files = new FTPFile[listing.length];
for (int i = 0; i < listing.length; i++) {
   files[i] = parser.parse(listing[i]);
}

Categories

...