[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [K12OSN] Way OT: scripting help



Dimitri Yioulos wrote:

Well actually, on second thought, I want my script to check to see if the file from the business partner is has been uploaded - the partner can be delayed, hence no file to transfer. The script is set to fire off at 9:10PM via cron. So, the transfer part of the script says "if the file isn't here, wait 15 minutes, then transfer, otherwise transfer". In theory, that should give the partner enough time to get the result file to us. However, that's not fool-proof - the partner could be delayed more than 15 minutes. So, from what I've read, maybe a "do while" construct would work better. But, of course, I'm not sure how to write that either. Anyway, if I use the "if then" contruct, as I currently have in my script, it still leaves me with finding a way to verify transfer.

I didn't quite follow the logic of what you are testing. If you want to test if a file transfer from the box running the script worked you can just repeat it with rsync - if it's already there the operation is very cheap. If you want to test if a file is available on the other system you can run the rsync to get it, then look at your directory contents.

while [ ! -e $FILENAME ]
do
 rsync -essh othermachine:/path/$FILENAME . || sleep 900
done

I usually try to write things so they do something sensible even if run at the wrong time or too often and just schedule several runs from cron instead of letting them wait, though.

--
  Les Mikesell
   les futuresource com


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]