File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes HELP: Java running ftp from xp to linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "HELP: Java running ftp from xp to linux" Watch "HELP: Java running ftp from xp to linux" New topic
Author

HELP: Java running ftp from xp to linux

achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Hi, I've a rather perplexing situation.
My Java program has a loop which tests whether a file exists on Linux and if it does, then ftp the file back from Linux to WindowsXP(sp2).
The problem is, if the file does not exist on Linux, ft creates a zero length file on XP which is misleading to XP and must be deleted. However we cannot delete it because ftp seems to have locked the file.
Following is stub code for the loop:

And this is the code which ftps the GetOK test file back from Linux:

Here is the method for executing the ftp, the ftp commands are in a text file

Here is the ftp commands in the text file

This generates the runtime error:
java.io.IOExceptiob: Bad file descriptor
.....at java.io.FileInputStream.available(Native Method)
.....at UseFTP.GetOK(UseFTP.java:552)
.....at UseFTP.Initialize(UseFTP.java:127)
.....at UseFTP.<init>(UseFTP:30)
.....at GetFiles.main(GetFiles.java:32)

The odd thing is when I crash out of the program UseFTP with a CTRL-C, the proper OKFile is ftp-ed back from Linux, overwriting the dud, zero length, OKFile created by ftp.
Any help greatly appreciated.


humanum errare est.
Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
Can't you check in Java before FTPing the file whether it's a 0-length file or not? If not, can't you run a cleanup program right after this one exits to see whether or not any 0-length files were created and delete them? I mean, if the file lock is being held by that other program, then you'll just have to wait until it releases the file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HELP: Java running ftp from xp to linux