Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
9.8k views
in Java FTP by
Hi all, is this code supposed to only work on windows machines?
I have the problem that the code I have for testing works fine (on a Windows machine), but as soon as I try and run the same code on a hpux sever, it fails, saying that it cannot find the file or directory of the file I am wanting to upload...
When if you try going to the said directory via unix, or even manually through FTP for that matter... they do actually exist.

com.enterprisedt.net.ftp.FTPException: Could not determine cwdir: No such file or directory.
        at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:800)
        at com.enterprisedt.net.ftp.FTPClient.initPut(FTPClient.java:1446)
        at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:1500)
        at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:1480)
        at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:1306)
        at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:1278)
        at com.enterprisedt.net.ftp.FTPUploadFile.run(FTPUploadFile.java:81)
Could not determine cwdir: No such file or directory.

Upload of: '/****/www/web/certificate/new/beta.html' to ****.***.****.***: /****/www/htdocs/certificate/new' FAILED


The final line is one I have output myself, detailing the location of the file to be upoaded, then the host: directory to upload to
(Some strings replaced with *** for security)


Has anybody had this problem, or know of a possible fix?

7 Answers

0 votes
by (162k points)
It's Java, and works fine on Unix.

You need to chdir() to the directory you want to place the file in before you transfer it.

Hi all, is this code supposed to only work on windows machines?
I have the problem that the code I have for testing works fine (on a Windows machine), but as soon as I try and run the same code on a hpux sever, it fails, saying that it cannot find the file or directory of the file I am wanting to upload...
0 votes
by
I am changing to the directory using the chdir method as you said.
As I said the ftp works fine on my windows machine.
ie it will upload a file from the hard dive (C:\) and place it in the directory I want, but when I attempt to do the same when I move the application to the server, and attempt to upload to the exact same location, it cannot seem to 'find' the file I want to upload.

Basicaly, the only thing that has changed is the location of the file to be uploaded, it is now a unix type path (ie begins with '/' )
0 votes
by (162k points)
The error you are getting looks like a server error.

Post the log file to give us more info
0 votes
by (240 points)
not sure if this will help, but i've experienced something like that before. What I had to do was cd into where the file is on the local directory, then run the application from there.

Try putting the file you want to upload in the same directory you're calling the app from.
0 votes
by
OK, here is the log file, with a few comments for clarity:

Connecting

Connecting to ******.***.*******.com/***.6.143.100:21

220 csand01 FTP server (Version wu-2.6.2(2) Mon Oct 7 11:09:08 MDT 2002) ready.

Logging in

---> USER webdoc

331 Password required for webdoc.

---> PASS ********

230 User webdoc logged in.

Setting up passive, ASCII transfers

---> TYPE I

200 Type set to I.

---> CWD /home/www/htdocs/certificate/new
[b][color=blue]The above directory is on the external server[/color][/b]

250 CWD command successful.

Directory before put:

---> PASV

227 Entering Passive Mode (***,6,143,100,175,122)

---> LIST -a .

150 Opening BINARY mode data connection for /bin/ls.

226 Transfer complete.

total 2

drwxr-xr-x   2 web             96 Oct 12 23:25 .

drwxrwxr-x   8 web           1024 Oct 18 23:46 ..

Putting file

---> PASV

227 Entering Passive Mode (***,6,143,100,52,248)

---> STOR /****/***/web/certificate/new/beta.html
[b][color=blue]The above file located on the local server, when testing on a windows machine, this begins with C:/ bla bla.. and works fine[/color][/b]

553 Could not determine cwdir: No such file or directory.

####### FTP Exception caught at: 1455
com.enterprisedt.net.ftp.FTPException: Could not determine cwdir: No such file or directory.
        at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:803)
        at com.enterprisedt.net.ftp.FTPClient.initPut(FTPClient.java:1446)
        at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:1504)
        at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:1484)
        at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:1306)
        at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:1278)
        at com.enterprisedt.net.ftp.FTPUploadFile.run(FTPUploadFile.java:84)
####### FTPException caught at: 1589
com.enterprisedt.net.ftp.FTPException: Could not determine cwdir: No such file or directory.
        at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:803)
        at com.enterprisedt.net.ftp.FTPClient.initPut(FTPClient.java:1446)
        at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:1504)
        at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:1484)
        at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:1306)
        at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:1278)
        at com.enterprisedt.net.ftp.FTPUploadFile.run(FTPUploadFile.java:84)

Transferred 0 bytes to remote host


I know the file and directory exists, simply by the fact that I look for it, using the exact path as used in the code, and there it is...[/b]
0 votes
by (162k points)
It is highly unlikely the below will work.

You need to "STOR beta.html", i.e. CWD to the destination directory and then supply just the remote filename, not the path.

---> STOR /****/***/web/certificate/new/beta.html
0 votes
by
OK, so the problem is fixed...
I did not have to cwd to the directory, my problem was that I was tokenizing still with "\\" and not "/"
I need to tokenize with "\\" when using windows, and "/" when using unix.

This being to the name of the file, getting it from the full file path.

I would not have found this out without your comment that I needed to call to upload with just a file name, and not a full path.

Thanks a lot!!!

Categories

...