Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.5k views
in Java FTP by (160 points)
Hi,
I am using edtftpj and have customised the Demo.java a little to ftp a file to a Zebra printer.
The printer's ftp server appears very basic in that it doesn't support many ftp commands,
However, I am able to open a dos command window, type in ftp <printer ip>, enter the password and do a put <filename>
This is exactly all I need to be able to do through Java.
Any ideas how I get around this 'PASV' not implemeted error?

Any suggestions would be much appreciated :P :P

here is the stackTrace:-
INFO [Demo] 31 Jul 2007 16:11:08.328 : Putting file
DEBUG [FTPControlSocket] 31 Jul 2007 16:11:08.328 : ---> PASV
DEBUG [FTPControlSocket] 31 Jul 2007 16:11:08.406 : 502 Command 'PASV' not implemented.
INFO [FTPControlSocket] 31 Jul 2007 16:11:08.406 : Expected reply code = [227]
ERROR [FTPClient] 31 Jul 2007 16:11:08.406 : Caught and rethrowing exception ininitPut() : Command 'PASV' not implemented.
com.enterprisedt.net.ftp.FTPException: Command 'PASV' not implemented.
at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:950)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocketPASV(FTPControlSocket.java:635)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocket(FTPControlSocket.java:450)
at com.enterprisedt.net.ftp.FTPClient.setupDataSocket(FTPClient.java:1726)

Thanks
Garret

2 Answers

0 votes
by (220 points)
Try:

FTPClient ftp = new FTPClient();
ftp.setConnectMode(FTPConnectMode.ACTIVE);  // This assumes that the default mode is FTPConnectMode.PASV
... 


Note: I have not tried the above code.

If that doesn't clear it up, then how about just ignoring the exception. I've noticed that some clients complaign that PASV isn't implemented, but the transfer goes ahead just fine. I guess, ignoring the exception would reguire a kludge, but it's not always a pretty world :wink:

One possible problem with my second suggestion, though -- it would probably be dependent on the text of the error message, which could change in future versions.
0 votes
by (160 points)
Thanks,
changing from PASV to ACTIVE did the trick as long as I just kept to doing a put (and not a dir listing etc)
:D

Categories

...