• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

FTP issue (using org.apache.commons.net.ftp)

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using org.apache.commons.net.ftp and have the following in my path:




My FTP server is on unix. Here is what I get when giving a command




on a windows command promt after connecting to the FTP Server output




I have an application that downloads the files from the above server, but I keep getting the following errors>>>>




Any idea what is wrong and how to fix it. Giving commands on command promt in windows works fine download, upload files. But when I use it through my program it gives errors. How else can get the files throgh java from FTP Server any other open source libraries available.

Thanks
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would be polite to show us the code where the exception is taking place so we can see what is going on, but it appears to be when you are attempting to list the files on the server. Perhaps this entry from the Jakarta Commons Net FAQ will help you along:


Q: On which server operating systems is FTPClient able to bring back a parsed listing?

A: Currently parsers have been written for UNIX, Windows, OS/2, Netware, VMS and OS400. These can be autodetected by the code without being specified. Additionally, the code correctly handles cases where NT or OS400 servers have been configured to look like unix servers. There is also a means of specifying a user-written parser by class name. All of these parsers return FTPFile objects with as much information about the file as can be gathered from the listing.

If none of these is sufficient, FTPClient.listNames() may always be called. This retrieves just the file name without other information.

 
Mike Boota
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Here is a code snippet, also ftp.listNames(); works fine it's ftp.listFiles(); that fails.....



Thanks
 
Sheriff
Posts: 27451
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay. Then it seems to me that the quote that Joe Ess posted exactly describes your problem and what you have to do about it. There is a collection of available parsers in the org.apache.commons.net.ftp.parser package; presumably whatever decides what parser to use doesn't think any of them are appropriate for getting file lists from that server. You could try forcing it to use one of them, or you could write your own. Or you could talk to the person who manages the server and ask them if they can reconfigure it to use a more well-known file list format.

(This is happening to you because the FTP specifications don't require a server to use any particular format when returning a list of files, so over the years a number of commonly-used formats have evolved. But nothing requires servers to use any of those formats except the convenience of their clients.)
 
Mike Boota
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any small example on how to use a specific parser. Even though listNames works fine just wanted if can still make use of listfiles.

As all I am trying to do is download files and then rename and some to delete.

Thanks
 
Mike Boota
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any help in how to set the parser. Thanks
 
Paul Clapham
Sheriff
Posts: 27451
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the source for some of the parsers built into the product you downloaded. It's open source so you can get the source code if you don't already have it. Then modify one of them to handle whatever the server is returning. It's going to take some debugging if the server's FTP file listing format is undocumented, which wouldn't surprise me.
 
Message for you sir! I think it is a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic