Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!pacbell.com!pacbell!well!moon!island!daniel From: daniel@island.COM (Daniel Smith - Fun Now, Worry Later) Newsgroups: comp.unix.shell Subject: Re: Creating a lock file in csh? Message-ID: <3940@island.COM> Date: 19 Apr 91 02:54:24 GMT References: <1991Apr15.205654.26253@unhd.unh.edu> <1991Apr16.175347.1082@odin.corp.sgi.com> Organization: Island Graphics, Marin County, California Lines: 68 > In article <1991Apr15.205654.26253@unhd.unh.edu> al@unhd.unh.edu (Anthony Lapadula) writes: > >I'll soon be writing a script (most likely in csh) that has at least > >one critical section ... > > > >I had thought that creating a lock file -- and checking for its presence > >when starting up -- would be a reasonable way to solve the problem. > > > >-- Anthony (uunet!unhd!al, al@cs.unh.edu) Lapadula [someone posted a good solution] And another use of a "lock file" is to flag when to stop doing something. This section is used to check how a tape extraction is going, which happens in the background...the foreground gets the task of reporting how much has been accomplished. It would be easy to check the existence of the lock file and avoind this whole section in the first place. [$CR is set to: `echo X | tr 'X' '\015'`] touch eps_extract_lock (tar xvf $tape_dev > tapelist) >& tape_errs ; rm eps_extract_lock & cat << +++ `clear` Extracting tape... +++ while ( -e eps_extract_lock ) @ so_far=`du -s | awk ' { print $1 }'` set percent_done=`bc` << +++ scale=1 ($so_far * 100) / $disk_space_needed +++ echo -n ' 'percent done: $percent_done + |\ tr '+' "$CR" sleep 1 if ( ! -z tape_errs) then cat << +++ `clear` It looks like there is a problem with the tape: `cat tape_errs` Perhaps one of these things occurred: tape got pulled out of the drive? cable loose or fell out? power turned off to tape drive? full moon? You may wish to try again with a different tape. Exiting this script. +++ goto bail_out endif end -- daniel@island.com Daniel Smith, Island Graphics, (415) 491 0765 x 250(w) daniel@world.std.com 4000 CivicCenterDrive SanRafael MarinCounty CA 94903 dansmith@well.sf.ca.us Fax: 491 0402 Disclaimer: Hey, I wrote it, not IG! falling/yes I'm falling/and she keeps calling/me back again - IJSaF, Beatles