It's not a secret anymore!*
The moose likes Java in General and the fly likes Accessing FTP Server using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Accessing FTP Server using Java" Watch "Accessing FTP Server using Java" New topic
Author

Accessing FTP Server using Java

Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Hello!,

I downloaded following class from the net that allows to login in FTP Server.

It was working fine, but when I added ls command (I have added comment see that) , it give error saying [i]500 'LS': command not understood.[i]

How to solve this problem?

Reg,
Chetan


My blood is tested +ve for Java.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

FTP is a pretty loose protocol. Some servers implement features that others do not. Depending on your server, "LS" may not be supported:

5. DECLARATIVE SPECIFICATIONS

5.1. MINIMUM IMPLEMENTATION

In order to make FTP workable without needless error messages, the
following minimum implementation is required for all servers:

TYPE - ASCII Non-print
MODE - Stream
STRUCTURE - File, Record
COMMANDS - USER, QUIT, PORT,
TYPE, MODE, STRU,
for the default values
RETR, STOR,
NOOP.

The default values for transfer parameters are:

TYPE - ASCII Non-print
MODE - Stream
STRU - File

All hosts must accept the above as the standard defaults.

RFC 959 - File Transfer Protocol
As a matter of fact, I don't see "LS" at all in the RFC.
Try using a command-line FTP client to log in. Typing in "help" may get you a list of valid commands for that server.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Arnold Reuser
Ranch Hand

Joined: Nov 20, 2003
Posts: 194
Maybe you could take also look at Commons Net for the base classes of FTP.
Around these bases classes Julian Robichaux has already written a wrapper that make the usage of FTP within java a bit less hard. You can find his code over here : http://www.nsftools.com/tips/JakartaFtpWrapper.java
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Thanks a lot!!

I will implement this thing.

Warm Regards,
Chetan
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Accessing FTP Server using Java
 
Similar Threads
java networking
sockets: How to receive server response in client
Client/Server networking
Server & Client are both waiting
Socket design question