• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

HELP: Java running ftp from xp to linux

 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic