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.
posted 11 years ago
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.