File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
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

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: Bad file descriptor Method) UseFTP.GetOK( UseFTP.Initialize( UseFTP.<init>(UseFTP:30) GetFiles.main(

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:
subject: HELP: Java running ftp from xp to linux
It's not a secret anymore!