Hi

I have a small problem getting the org.apache.commons.net.ftp.FTPClient to work correctly.

I attached a small test case that showcases the problem on my linux system running jdk1.6.0_03 from sun.

The output from the program looks like this:

listing:
exit
connected

and as can be seen it seems to do some kind of exit on line 28, it never reaches the println statement on line 32.

If i sniff the network traffic for the connection i notice this exchange after the login (full dump attached as tcpdump.txt):

me: SYST
server: 215 UNIX Type: L8
me:
server: 500 OOPS:
server: vsf_sysutil_recv_peek: no data

What i feel is strange is that the ftp client doesn't send a PASV command and i can't see any LIST command either.

And if the ftp client recieves an error, shouldn't it throw an exception instead of exiting totally?

As I'm new to this library it could maybe be that i have missunderstood how to use it, in that case i would appreciate some hints on where to read up on the usage pattern i should have.

--
Alexander Kjäll
Developer
[EMAIL PROTECTED]

import org.apache.commons.net.ftp.*;
import java.io.*;

public class j {
	public static void main(String[] args) {
		FTPClient ftp = new FTPClient();

		boolean error = false;
		String server = "ftp.kernel.org";

		try {
			ftp.connect(server);
			int reply = ftp.getReplyCode();

			if(!FTPReply.isPositiveCompletion(reply)) {
				ftp.disconnect();
				System.err.println("FTP server refused connection.");
				System.exit(1);
			}

			ftp.login("anonymous", "[EMAIL PROTECTED]");
			ftp.enterLocalPassiveMode();

			ftp.changeWorkingDirectory("/");


			System.out.println("listing: ");
			final FTPFile[] files = ftp.listFiles("/");
			for(int i = 0; i < files.length; ++i) {
				System.out.println("file: " + files[i]);
			}
			System.out.println("listing done");

			// transfer files
			ftp.logout();
		} catch(Exception e) {
			error = true;
			System.out.println("error");
			e.printStackTrace();
		} finally {
			System.out.println("exit");
			if(ftp.isConnected()) {
				System.out.println("connected");
				try {
					ftp.disconnect();
				} catch(IOException ioe) {
				// do nothing
				}
				System.exit(error ? 1 : 0);
			}
		}
	}
}
[EMAIL PROTECTED]:/tmp$ sudo tcpdump -A -s2000 host ftp.kernel.org
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 2000 bytes
12:38:58.412516 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: S 
2710334191:2710334191(0) win 5840 <mss 1460,sackOK,timestamp 1342010153 
0,nop,wscale 7>
E..<[EMAIL PROTECTED]@.. ..............j.........h..........
O.s)........
12:38:58.587378 IP pub1.kernel.org.ftp > alex-desktop.local.39681: S 
1434883922:1434883922(0) ack 2710334192 win 5792 <mss 1460,sackOK,timestamp 
4057054973 1342010153,nop,wscale 5>
E..<[EMAIL PROTECTED]
....O.s)....
12:38:58.587421 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: . ack 1 win 
46 <nop,nop,timestamp 1342010197 4057054973>
[EMAIL PROTECTED]@..'..............j.U..S.....*.....
O.sU....
12:38:58.764102 IP pub1.kernel.org.ftp > alex-desktop.local.39681: P 1:33(32) 
ack 1 win 181 <nop,nop,timestamp 4057055150 1342010197>
E..T([EMAIL PROTECTED]
....O.sU220 Welcome to ftp.kernel.org.

12:38:58.764166 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: . ack 33 win 
46 <nop,nop,timestamp 1342010241 4057055150>
[EMAIL PROTECTED]@..&..............j.U..s.....-.....
O.s.....
12:38:58.774340 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: P 1:17(16) 
ack 33 win 46 <nop,nop,timestamp 1342010244 4057055150>
[EMAIL PROTECTED]@.................j.U..s.....5.....
O.s.....USER anonymous

12:38:58.949215 IP pub1.kernel.org.ftp > alex-desktop.local.39681: . ack 17 win 
181 <nop,nop,timestamp 4057055335 1342010244>
[EMAIL PROTECTED]
...gO.s.
12:38:58.949249 IP pub1.kernel.org.ftp > alex-desktop.local.39681: P 33:67(34) 
ack 17 win 181 <nop,nop,timestamp 4057055335 1342010244>
E..V)[EMAIL PROTECTED]
...gO.s.331 Please specify the password.

12:38:58.950187 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: P 17:39(22) 
ack 67 win 46 <nop,nop,timestamp 1342010288 4057055335>
[EMAIL PROTECTED]@.................k.U..............
O.s....gPASS [EMAIL PROTECTED]

12:38:59.125259 IP pub1.kernel.org.ftp > alex-desktop.local.39681: P 67:94(27) 
ack 39 win 181 <nop,nop,timestamp 4057055511 1342010288>
E..O)[EMAIL PROTECTED]
....O.s.230-                        Welcome to the

12:38:59.125293 IP pub1.kernel.org.ftp > alex-desktop.local.39681: P 94:100(6) 
ack 39 win 181 <nop,nop,timestamp 4057055511 1342010288>
E..:)[EMAIL PROTECTED]
....O.s.230-

12:38:59.125563 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: . ack 100 
win 46 <nop,nop,timestamp 1342010332 4057055511>
[EMAIL PROTECTED]@..#..............k.U.......
O.s.....
12:38:59.300055 IP pub1.kernel.org.ftp > alex-desktop.local.39681: . 
100:1548(1448) ack 39 win 181 <nop,nop,timestamp 4057055686 1342010332>
E...)[EMAIL PROTECTED]
....O.s.230-                    LINUX KERNEL ARCHIVES
230-                        ftp.kernel.org
230-
230-                "Much more than just kernels"
230-
230-       IF YOU'RE ACCESSING THIS SITE VIA A WEB BROWSER
230-            PLEASE USE THE HTTP URL BELOW INSTEAD!
230-
230----->       If you are looking for mirror sites, please go       <----
230----->                   to mirrors.kernel.org instead                <----
230-
230-This site is provided as a public service by the Linux Kernel
230-Organization, a California nonprofit corporation.  Bandwidth is
230-provided by The Internet Software Consortium, Inc.  Our servers are
230-located in San Francisco and Palo Alto, California; Corvallis, Oregon;
230-Amsterdam, Netherlands and Ume.., Sweden; use in violation of any
230-applicable laws strictly prohibited.
230-
230-Due to U.S. Exports Regulations, all cryptographic software on this
230-site is subject to the following legal notice:
230-
230-    This site includes publicly available encryption source code
230-    which, together with object code resulting from the compiling of
230-    publicly available source code, may be exported from the United
230-    States under License Exception "TSU" pursuant to 15 C.F.R. Section
230-    740.13(e).
230-
230-This legal notice applies to cryptographic software only.  Please see
230-the Bureau of Industry and Security (http://www.bis.doc.gov/) for more
230-information about current U.S. regulations.
230-
230-Neither the Linu
12:38:59.300116 IP pub1.kernel.org.ftp > alex-desktop.local.39681: P 
1548:2252(704) ack 39 win 181 <nop,nop,timestamp 4057055686 1342010332>
E...)[EMAIL PROTECTED])............U..^..k......8.....
....O.s.x Kernel Organization, nor its sponsors make any
230-guarantees, explicit or implicit, about the contents of this site.
230-Use at your own risk.
230-
230-This site is accessible via the following mechanisms:
230-
230-    FTP             ftp://ftp.kernel.org/pub/
230-    HTTP            http://www.kernel.org/pub/
230-    RSYNC           rsync://rsync.kernel.org/pub/
230-
230-NFS and SMB/CIFS are no longer available.
230-
230-For comments on this site, please contact <[EMAIL PROTECTED]>.
230-Please do not use this address for questions that are not related to
230-the operation of this site.  Please see our homepage at
230-http://www.kernel.org/ for links to Linux documentation resources.
230-
230 Login successful.

12:38:59.300834 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: . ack 2252 
win 91 <nop,nop,timestamp 1342010375 4057055686>
[EMAIL PROTECTED]@.."..............k.U......[.......
O.t.....
12:38:59.318079 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: P 39:46(7) 
ack 2252 win 91 <nop,nop,timestamp 1342010380 4057055686>
E..;[EMAIL PROTECTED]@.................k.U......[B......
O.t.....CWD /

12:38:59.493060 IP pub1.kernel.org.ftp > alex-desktop.local.39681: P 
2252:2289(37) ack 46 win 181 <nop,nop,timestamp 4057055879 1342010380>
E..Y)[EMAIL PROTECTED]
....O.t.250 Directory successfully changed.

12:38:59.499559 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: P 46:52(6) 
ack 2289 win 91 <nop,nop,timestamp 1342010425 4057055879>
E..:[EMAIL PROTECTED]@.................k.U..C...[N......
O.t9....SYST

12:38:59.673384 IP pub1.kernel.org.ftp > alex-desktop.local.39681: P 
2289:2308(19) ack 52 win 181 <nop,nop,timestamp 4057056060 1342010425>
E..G)[EMAIL PROTECTED]
...<O.t9215 UNIX Type: L8

12:38:59.680558 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: F 52:52(0) 
ack 2308 win 91 <nop,nop,timestamp 1342010470 4057056060>
[EMAIL PROTECTED]@.................k#U..V...[.v.....
O.tf...<
12:38:59.854550 IP pub1.kernel.org.ftp > alex-desktop.local.39681: P 
2308:2318(10) ack 53 win 181 <nop,nop,timestamp 4057056241 1342010470>
E..>)[EMAIL PROTECTED]
....O.tf500 OOPS: 
12:38:59.854596 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: R 
2710334244:2710334244(0) win 0
E..([EMAIL PROTECTED]@.................k$....P....C..
12:38:59.854617 IP pub1.kernel.org.ftp > alex-desktop.local.39681: P 
2318:2348(30) ack 53 win 181 <nop,nop,timestamp 4057056241 1342010470>
E..R)   @.8...............U..`..k$.....n.....
....O.tfvsf_sysutil_recv_peek: no data
12:38:59.854625 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: R 
2710334244:2710334244(0) win 0
E..([EMAIL PROTECTED]@.................k$....P....C..
12:38:59.854634 IP pub1.kernel.org.ftp > alex-desktop.local.39681: P 
2348:2350(2) ack 53 win 181 <nop,nop,timestamp 4057056241 1342010470>
E..6)
@.8...............U..~..k$.....*.....
....O.tf

12:38:59.854642 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: R 
2710334244:2710334244(0) win 0
E..([EMAIL PROTECTED]@.................k$....P....C..
12:38:59.855939 IP pub1.kernel.org.ftp > alex-desktop.local.39681: F 
2350:2350(0) ack 53 win 181 <nop,nop,timestamp 4057056241 1342010470>
E..4)[EMAIL PROTECTED]<.....
....O.tf
12:38:59.855950 IP alex-desktop.local.39681 > pub1.kernel.org.ftp: R 
2710334244:2710334244(0) win 0
E..([EMAIL PROTECTED]@.................k$....P....C..


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to