The Artima Developer Community
Sponsored Link

Java Answers Forum
interacting with ftp prompt when using apache commons net package

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Stephen Huey

Posts: 10
Nickname: stephen
Registered: Aug, 2003

interacting with ftp prompt when using apache commons net package Posted: Aug 8, 2003 9:04 AM
Reply to this message Reply
Advertisement
I'm trying to use the FTPClient provided in the Apache Commons Net code: http://jakarta.apache.org/commons/net/apidocs/org/apache/commons/net/ftp/FTPClient.html

It has a method called listNames() that returns a String of the files' names in the current directory. The problem is that the site I'm ftping into presents to me a virtual file system, and the files "listed" are not constructed (by servlets?) until I try to download them. On this system, when I ftp in via a command prompt, I must type "dir" at the ftp prompt to get a listing (though the listing is not a typical file system one, seeing as how it includes other things like batch ID, status codes, etc), and then "get" with parameters in order to download the file I want. All of the "file names" are actually identical, and their batch ID numbers are unique (that's what I ask for with that get command). When I call FTPClient's listNames(), whatever it does returns a string that has only the pseudo filename (which is useless to me), and does not obtain any of that other data that I can see when I type dir at the command line.

So, after logging in, I need a way to pretend I'm sitting at an ftp prompt with a command line terminal and can type in "dir" and hit enter. I thought that maybe FTPClient's superclass (FTP) could help me out, because it has a method called sendCommand(String s). However, when I send "dir" and call FTPClient.getReplyString(), the reply string simply says that the dir command was not understood! So I'm not sure what that sendCommand is for, and I can't find any other suitable methods for executing a direct command that does something very explicit rather than going through a black box, and I'm hoping that someone out there understands this API better than me or has a bright idea about how to handle this!

Thanks for your help,
Stephen

sendCommand in class FTP:
http://jakarta.apache.org/commons/net/apidocs/org/apache/commons/net/ftp/FTP.html

Topic: can a java pgm detect the installation of apache and tomcat? Previous Topic   Next Topic Topic: Converting from canvas to JPanel

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use