[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Thu Feb 17 23:37:59 2005 -->
- <!--x-from-r13: Rbj.Vhefg ng zvaqfcevat.pbz (Rbj Vhefg) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: Pine.LNX.4.44.0502152230590.2264-[email protected] -->
- <!--x-reference: [email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] Bash scripting question #2 -->
- <li><em>date</em>: Thu Feb 17 23:37:59 2005</li>
- <li><em>from</em>: Dow.Hurst at mindspring.com (Dow Hurst)</li>
- <li><em>in-reply-to</em>: <<a href="msg00626.html">[email protected]</a>></li>
- <li><em>references</em>: <[email protected]> <<a href="msg00626.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] Bash scripting question #2</li>
I have a script that I'd like to have watch 10 files and when the last
one is removed, then move on to the next command in the script. I
initially tried testing for the existence of all 10 files but I know I
have the syntax wrong.
Here is the while loop that failed:
## Wait and watch for locks to disappear
cd $CWD
LK=biased.lck
TERM="BatchMin normal termination"
while :
do
if [ -f $CWD/00/biased/$LK || $CWD/01/biased/$LK ||
$CWD/02/biased/$LK || $CWD/03/biased/$LK || $CWD/04/biased/$LK \
|| $CWD/05/biased/$LK || $CWD/06/biased/$LK ||
$CWD/07/biased/$LK || $CWD/08/biased/$LK || $CWD/09/biased/$LK ]
then sleep 900
elif [ "$TERM"="`grep 'BatchMin normal termination'
$CWD/09/biased/biased.log`" ]
then echo "09 biased terminated normally"
break
else echo "09 biased failed!"
sleep 3600
fi
done
sync
sleep 10
echo "Finished biased runs "; date
#End Section that didn't work###################
Here is the while loop that watches the last job only, however, it can
run longer than the next to the last job in certain cases. So this
isn't a robust solution:
echo "Starting biased ";date
cd $CWD/00/biased
./bminv < ./biased.com > ./biased.log &
echo "Biased run 00 PID = $!"
sleep 300
cd $CWD/01/biased
./bminv < ./biased.com > ./biased.log &
echo "Biased run 01 PID = $!"
sleep 300
cd $CWD/02/biased
./bminv < ./biased.com > ./biased.log &
echo "Biased run 02 PID = $!"
sleep 300
cd $CWD/03/biased
./bminv < ./biased.com > ./biased.log &
echo "Biased run 03 PID = $!"
sleep 300
cd $CWD/04/biased
./bminv < ./biased.com > ./biased.log &
echo "Biased run 04 PID = $!"
sleep 300
cd $CWD/05/biased
./bminv < ./biased.com > ./biased.log &
echo "Biased run 05 PID = $!"
sleep 300
cd $CWD/06/biased
./bminv < ./biased.com > ./biased.log &
echo "Biased run 06 PID = $!"
sleep 300
cd $CWD/07/biased
./bminv < ./biased.com > ./biased.log &
echo "Biased run 07 PID = $!"
sleep 300
cd $CWD/08/biased
./bminv < ./biased.com > ./biased.log &
echo "Biased run 08 PID = $!"
sleep 300
cd $CWD/09/biased
./bminv < ./biased.com > ./biased.log &
echo "Biased run 09 PID = $!"
sleep 5
## Wait and watch for locks to disappear
cd $CWD
LK=biased.lck
TERM="BatchMin normal termination"
while :
do
if [ -f $CWD/09/biased/$LK ]
then echo "Sleeping while waiting on biased ";date;sleep 900
elif [ "$TERM"="`grep 'BatchMin normal termination'
$CWD/09/biased/biased.log`" ]
then echo "09 biased terminated normally"
break
else echo "09 biased failed!"
sleep 3600
fi
done
sync
sleep 5
echo "Finished biased runs "; date
#END of section that works######################
What is wrong with the original while loop file test? Thanks for the help,
Dow
Geoffrey wrote:
> John Mills wrote:
>
>> ALErs -
>>
>> Should be simple, but I don't see it:
>>
>> I have a directory with softlinks to a number of files that no longer
>> exist, along with links to files that _do_ exist.
>>
>> How can I selectively list those links which are _not_ satisfied, so
>> I can remove them at one go, while ignoring those for which the
>> linked files still exist?
>
>
> rm $(for fn in *; do
> test -f $fn || echo $fn
> done)
>
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00619" href="msg00619.html">[ale] Bash (or whatever) question</a></strong>
<ul><li><em>From:</em> johnmills at speakeasy.net (John Mills)</li></ul></li>
<li><strong><a name="00626" href="msg00626.html">[ale] Bash (or whatever) question</a></strong>
<ul><li><em>From:</em> esoteric at 3times25.net (Geoffrey)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00696.html">[ale] [OT] I just bought an iBook, what now</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00698.html">[ale] William Gates -- movie villian</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00701.html">[ale] Bash scripting question #2</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00632.html">[ale] BASH script - wait for CD insert</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00697"><strong>Date</strong></a></li>
<li><a href="threads.html#00697"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>