Connect to FTP Server with examples.telnet.TelnetClientExample.java

Q

Can I connect to a FTP server with examples.telnet.TelnetClientExample.java program?

✍: FYIcenter.com

A

Yes, you can connect to a FTP server with examples.telnet.TelnetClientExample.java program. But you have to know very well about the FTP protocol to be able to change directory or download files.

Here is an example of using examples.telnet.TelnetClientExample.java program to connect to ietf.org FTP server:

C:\fyicenter>\local\jdk-1.8.0\bin\java 
   -cp .;C:\local\commons-net-3.5\commons-net-3.5.jar
        ;C:\local\commons-net-3.5\commons-net-examples-3.5.jar 
   examples.telnet.TelnetClientExample ietf.org 21

TelnetClientExample
Type AYT to send an AYT telnet command
Type OPT to print a report of status of options (0-24)
Type REGISTER to register a new SimpleOptionHandler
Type UNREGISTER to unregister an OptionHandler
Type SPY to register the spy (connect to port 3333 to spy)
Type UNSPY to stop spying the connection
Type ^[A-Z] to send the control character; use ^^ to send ^

220 FTP server ready

USER anonymous
331 Anonymous login ok, send your complete email address as your password
PASS jo@jo.com
230 Anonymous access granted, restrictions apply

CWD rfc
250-
 *====================================================================*
 *                                                                    *
 * This directory is maintained by the RFC Editor.  If you experience *
 * any problems, please report them to rfc-editor@rfc-editor.org.     *
 *                                                                    *
 *====================================================================*
250 CWD command successful

PASV
227 Entering Passive Mode (4,31,198,44,241,19).
   (go to another command window)
   (telnet 4,31,198,44 61715)
   (   port is calculated as 61715=241*256+19)
   
LIST
150 Opening ASCII mode data connection for file list
   (directory list will displayed in the other window)
   
226 Transfer complete

 

Using commons-net.jar in Java Programs

⇒⇒FAQ for Apache commons-net.jar

2017-04-08, 306👍, 0💬