Unix ksh: do a command until condition is met
Posted on 2010-11-17
Again I need your help.
A file is ftp-ed, upon completion of the transfer a signal is to be given that it can be processed.
First thing was to be sure the file was fully written, I found in the archives guidance on using 'fuser' for that.
So I have:
`/usr/sbin/fuser -f $FILENAME 2>/dev/null 1>path/to/fuser.txt`
As long as the text in fuser.txt is not 'blank' (e.g. a process number is returned), the file is 'in use'.
Until the file is 'blank' the fuser cmd should be redone (every minute or so).
Once there is no text in fuser.txt (size of the file is not '0' but '1' actually) a new command can be launched.
I have been checking 'while' scenario's but it is beyond my skills to implement.
Many thanks in advance.