On Thu, Jun 01, 2006 at 11:06:27PM +0100, Wayne Stallwood wrote:
#!/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
^ missing a fi, but that's probably not the issue ;)
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!!!
Rough wondering guess... does this file *happen* to be a binary file? Could it, perhaps, contain a null character, or something else that wouldn't fit in with an ascii file transfer? Might be worth adding a command in there, the binary command, just before the put $file.
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 ?
That it would, you *could* wait on an lsof of the file to return nothing, I suppose... not sure if that even exists on that OS though, good luck!
oh and it's not the ftp transfer that's causing the problem because I can do the transfer manually and all is well.
Hmm, using exactly that set of commands? does it work if you run that script exactly as is?
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.
Hmm, maybe use smbclient to talk to the windows box? Or maybe ditch the windows box entirely, you don't really need it, right? ;)
Or the windows box could use NFS to talk to the SCO box... or maybe a different FTP client, something along the lines of lftp?
I hope you've got a large field full of Goat's that are ready for sacrificing ;)
Cheers,