Home » Infrastructure » Unix » Need help in not fetching a file while it is being used
Need help in not fetching a file while it is being used [message #551396] Tue, 17 April 2012 22:06 Go to next message
world.apps
Messages: 70
Registered: January 2007
Location: Hyderabad
Member
Hi All,

We have a host program in oracle when we run this program this connects to specified ftp and will get the file into local server.

We are facing a problem like when file in ftp server is in writing mode/not completed yet, this program is getting the incomplete file.

Could anyone please help me how to control this.

Thanks in advance.

[Updated on: Tue, 17 April 2012 22:08]

Report message to a moderator

Re: Need help in not fetching a file while it is being used [message #551413 is a reply to message #551396] Wed, 18 April 2012 01:09 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
How anyone can know if other one is currently writing into a remote file?
If you can answer this then you most likely do it in Oracle.

You can use another file that contains some specific information (like "writing file XXX complete") and you test this other file before tranfering the first one.

Regards
Michel
Re: Need help in not fetching a file while it is being used [message #551418 is a reply to message #551396] Wed, 18 April 2012 02:21 Go to previous messageGo to next message
John Watson
Messages: 8922
Registered: January 2010
Location: Global Village
Senior Member
You could create a file watcher job, it's described in the docs:
http://docs.oracle.com/cd/E14072_01/server.112/e10595/scheduse005.htm#CIAJIADA
Re: Need help in not fetching a file while it is being used [message #551465 is a reply to message #551418] Wed, 18 April 2012 09:12 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
The way I have handled this is as follows.
add a line or two to the script that creates the file.
have a subdirectory one level below where the file is being written/created called "completed".
the new line in the script would be as below
mv $FILENAME ./completed
when ./completed/$FILENAME exists, it is assured to be whole & complete and available for FTP transfer.
Re: Need help in not fetching a file while it is being used [message #551786 is a reply to message #551396] Fri, 20 April 2012 10:09 Go to previous messageGo to next message
LKBrwn_DBA
Messages: 487
Registered: July 2003
Location: WPB, FL
Senior Member
An alternative to BlackSwan's suggestion is to ftp the file with different name then once the ftp finishes, it rename the file. Kinda like this:
ftp> get myfile.txt myfile.txt.busy
ftp> !mv myfile.txt.busy myfile.txt
ftp> bye

[Updated on: Fri, 20 April 2012 10:12] by Moderator

Report message to a moderator

Re: Need help in not fetching a file while it is being used [message #551855 is a reply to message #551396] Sat, 21 April 2012 09:31 Go to previous messageGo to next message
world.apps
Messages: 70
Registered: January 2007
Location: Hyderabad
Member
Hi All,

Thanks for your help. As per the BlackSwan note we requested the third party to add a line at the end of the file to achive this requirment. But they are not willing to add anything to the file.

I tried with the commands provided by LKBrwn_DBA but it appears to be this may fail in some cases. Can you please correct me if my below assumptions are wrong.

Quote:

ftp> get myfile.txt myfile.txt.busy

this is transfering the file to unix server with different file name.

ftp> !mv myfile.txt.busy myfile.txt

this is moving the file to unix server by changing the file name. But i suspect this may happen while file is being used/written.

ftp> bye


Thanks

[Updated on: Sat, 21 April 2012 11:41] by Moderator

Report message to a moderator

Re: Need help in not fetching a file while it is being used [message #551857 is a reply to message #551855] Sat, 21 April 2012 10:02 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
I have brute force & 100% inefficient solution.
FTP every file twice.
Only when size of second GET matches the first file size, it is safe to apply this file.
Re: Need help in not fetching a file while it is being used [message #551859 is a reply to message #551857] Sat, 21 April 2012 11:10 Go to previous messageGo to next message
world.apps
Messages: 70
Registered: January 2007
Location: Hyderabad
Member
Thanks. May i ask you to post this solution.

Also there is a ftp command 'modtime' this is giving the file modification time in remote server. Could you please suggest me if this can be any useful for this requirement.
Re: Need help in not fetching a file while it is being used [message #551862 is a reply to message #551859] Sat, 21 April 2012 11:42 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You got several solutions, why don't you try to develop them by yourself and find which one better fit your needs?

Regards
Michel

[Updated on: Sat, 21 April 2012 11:43]

Report message to a moderator

Re: Need help in not fetching a file while it is being used [message #551881 is a reply to message #551862] Sat, 21 April 2012 14:53 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Thanks. May i ask you to post this solution.
I have no interest to implement any solution for you.

>Also there is a ftp command 'modtime' this is giving the file modification time in remote server.
>Could you please suggest me if this can be any useful for this requirement.
I have NO idea if it could be useful or not.
You would know for sure after doing some basic Proof of Concept testing.
Previous Topic: automate to starting and shutdown of database
Next Topic: Kernel patch upgrade in sun solaris
Goto Forum:
  


Current Time: Fri Mar 29 01:23:14 CDT 2024