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

Re: [K12OSN] Way OT: scripting help



On Wednesday 23 May 2007 1:38 pm, Les Mikesell wrote:
> 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
>
> _______________________________________________
> K12OSN mailing list
> K12OSN redhat com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>

Apologies if my description of what I'm after isn't clear above.  I want to 
make sure our business partner had uploaded it's file to the ftp server, then 
transfer it, then make sure an exact copy actually did get transfered, then 
delete the file on the ftp server next day.  Does the construct:

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

wait 15 minutes if the file hasn't been uploaded to the ftp server, then do 
the tranfer, otherwise do the transfer (doesn't look like it does)?  How 
would I then repeat the rsync to test that the transfer actually happened 
and, if not (for whatever reason), try the transfer again.  Now, I hope I'm 
not pushing the lists good nature, but how might I log that the transfer took 
place successfully (doesn't matter whether it on the ftp server or the file 
server that it's being transferred to)?

Many thanks.

Dimitri

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


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