Not exactly a Linux question, but the answer may equally apply and it's confusing the living daylights out of me so-
I have a client with a SCO box...the application it runs is sometimes made to generate a file that has to magically appear a bit later on another (Windows) box.
Due to visionFS (sort of like Samba but not as nice) not being completely happy talking to Windows Server 2003 (or vice versa) the method that was chosen when this was implemented by whoever was FTP.
So there is a cron job that looks roughly like this
#!/bin/sh userid=foo pword=bar host=windowsbox file=transferfile.csv
if [ -e $file ] then ftp -i -n $host <<putfile user $userid $pword cd /location/on/windows/box lcd /file/location put $file putfile echo file transferred mv $file $file.sent else exit
The odd thing is that the file is nearly always truncated...I thought at first we were getting unlucky and the script was transferring it before app had finished writing it. So I tried inserting a wait in the script just before the ftp transfer bit...So then it looked for the file and if it existed waited 2 minutes (plenty of time for the app to finish with the file) and only then transferred it...If anything this seemed to make things worse!!!
Also interestingly the $file.sent (ie the moved copy of $file) is always complete. But I am guessing because it's a move it would be because the unlinked filename handle would be working until the app let go of it right ?
oh and it's not the ftp transfer that's causing the problem because I can do the transfer manually and all is well. Can't help thinking that there is a better way of doing this...but any ideas on how to re-implement or fix the current method are very welcome.