[TriLUG] Making a bg'd bash script wait for user intervention

Neil L. Little nllittle at vnet.net
Tue Oct 19 22:28:58 EDT 2004


Back in the day ...
When working in my first tech job as a computer operator we use to run a 
lot of scripts in batch that required certain files or infomation to be 
processed before continuing data processing. What we would do was set 
flags. Maybe checking for the presence of a file or maybe a string value 
in a file. You always had to remember to do clean up before or after but 
it worked pretty well. It was a good simple way to control script 
action. Without having to run the script from a console.

The company was Data General. The os was called AOS and ran on a mini 
called an MV6000 by the way. Real "old" stuff.

Neil Little

>Date: Mon, 18 Oct 2004 16:17:39 -0400
>From: Jeremy Portzer <jeremyp at pobox.com>
>Subject: Re: [TriLUG] Making a bg'd bash script wait for user
>	intervention
>To: Triangle Linux Users Group discussion list <trilug at trilug.org>
>Message-ID: <1098130658.30022.106.camel at jeremy.dtcc.cc.nc.us>
>Content-Type: text/plain; charset="us-ascii"
>
>On Mon, 2004-10-18 at 15:09, Brian Henning wrote:
>  
>
>>> Hi Y'all,
>>>   I'm working on a set of scripts for backups, and I've hit a snag in a
>>> script that burns images to CDs.  I need it to wait for user intervention in
>>> certain situations (no CD in drive, CD not blank, swap CDs now, etc).  I've
>>> got the various conditions mapped out in the script; all I need is a way to
>>> make it wait for me to say "go", basically.  The trick is that the process
>>> may be backgrounded, so it can't be simply waiting for Enter on stdin (or
>>> can it?).  I tried suspend, but I get
>>> suspend: cannot suspend: no job control
>>> 
>>> Is there another simple method to make a bash script wait for a signal?  Or
>>> else, what do I need to do to make suspend work?
>>    
>>
>
>I just re-read your message after reading Ryan's first, and I see what
>you're trying to do with the suspend command.  This looks like an ideal
>solution, because you *can't* wait for Enter on stdin, because you don't
>really have access to stdin if the script is backgrounded.  However,
>silly question... what does the first line of your script look like, is
>it this:  #!/bin/sh ?  If so, you are running bash in sh-compatible
>mode, which doesn't have job control, and possibly the reason for this
>error.  If you change that to /bin/bash it could fix that.  Maybe I'm
>OLF, not sure.
>
>You would probably want to write a second "helper" script that would
>find the process ID of the first script, and then run "kill -CONT <pid>"
>to restart it.
>
>Neat idea, good luck!
>
>Jeremy
>
> -- 
> /---------------------------------------------------------------------\ 
> | Jeremy Portzer jeremyp at pobox.com trilug.org/~jeremy | | GPG 
> Fingerprint: 712D 77C7 AB2D 2130 989F E135 6F9F F7BC CC1A 7B92 | 
> \---------------------------------------------------------------------/ 
> -------------- next part -------------- A non-text attachment was 
> scrubbed... Name: not available Type: application/pgp-signature Size: 
> 189 bytes Desc: This is a digitally signed message part Url : 
> http://www.trilug.org/pipermail/trilug/attachments/20041018/7204f442/attachment-0001.bin 
> ------------------------------
>



More information about the TriLUG mailing list