Reading a file that is already open by another process

hi,

I'm using HP unix tru64 & Win XP.

i'm download a file from winxp to unix using ftp.

how to know whether a remote file is currently being used by the process or not? (my loaction unix server)

Which process?

"A remote file being in use by a process..." Sorry, I don't understand what you mean. Remote in the terms if you can check from your Unix box if the file you are downloading is currently in use by some process on the XP box :confused: Maybe you describe a bit more, what you want to know.

Basically on Unix you can check with "fuser" if files are in use.

i have try explain below:

  1. application1 create A1 file and write some text to A1 file.
    application1 running windows server

  2. application2 download A1 file from windows server to unix server.
    application2 running unix server

problem is application1 writing text to A1 file(not finish) and this time try download application2 file A1.

application2 did download not complete A1 file.

Ah ok, understood. We solved such issues usually by sending an ok-flag file, just an empty file, with some special name, that you check on the UNIX side and if it arrived as 2nd file, you know that the 1st file (your datafile) has completely arrived. At least if no error occured.
Don't forget to remove the ok-flag file when everything is done, so the next ftp can come ^^

Thank you suggestion. your idea is could solve my problem.
I understood that app1 insert ok-flag file last line.
app2 check ok-flag than have ok-flag completely download file.
it's right?

Nope:

  1. ftp data file windows -> unix
  2. after that ftp empty ok-file windows -> unix
  3. check if ok file has been received on unix which signals that the data file transfer has already been made
  4. start your processing of the data file

ok? :slight_smile:

sorry, i don't understand.
what's mean "empty ok-file" ?

Some file without any content named "ok-file". It is only there if everything has been transferred correctly so if the ftp-process transfers this file, the process knows (by checking for the existence of this file) that everything has been transferred. If the initial check for the existence of the file fails the process would know that the data are incomplete and it has to wait.

I hope this helps.

bakunin