[comp.unix.questions] Quiet background proc. in CSH

wiml@blake.acs.washington.edu (William Lewis) (11/17/89)

   I've written a shell script (in C shell; it's a .login script) that
invokes a couple of background pipes. The pipes work fine but when they
finish, they print a 

  [1] Done      ( blah blah very long pipe here ... )

 message. Is there any way to get rid of this message? Preferably a way
that would also get rid of the

 [1] 5628  

  message as well, although this is less important as it's short, unobtrusive,
always in the same place, etc. 
   Any help appreciated =8) (The FM for csh doesn't seem to say anything 
about this...)

     --- phelliax
-- 
wiml@blake.acs.washington.edu        (206)526-5885      Seattle, Washington

maart@cs.vu.nl (Maarten Litmaath) (11/17/89)

In article <4491@blake.acs.washington.edu> wiml@blake.acs.washington.edu (William Lewis) writes:
\
\   I've written a shell script (in C shell; it's a .login script) that
\invokes a couple of background pipes. The pipes work fine but when they
\finish, they print a 
\
\  [1] Done      ( blah blah very long pipe here ... )
\
\ message. Is there any way to get rid of this message? Preferably a way
\that would also get rid of the
\
\ [1] 5628  
\
\  message as well, [...]

You could put the pipelines in a separate script:

	% cat .login
	...
	background_script < /dev/null >& /dev/null
	...
	% cat background_script
	#!/bin/csh -f
	pipeline_1 &
	pipeline_2 &
	...

If your `background_script' could be written just as easily in Bourne shell
language:

	% cat background_script
	#!/bin/sh
	(
		pipeline_1 &
		pipeline_2 &
		...
	) &

...which gives control back to .login faster.
-- 
[...] like a roving gang.  "Ah, here's a NEW almost-empty group to post train
schedules and core dumps in!"  (Joe Buck) | maart@cs.vu.nl, mcsun!botter!maart

wiml@blake.acs.washington.edu (William Lewis) (11/18/89)

   Last night I poasted a question, asking how to quietly invoke
background processes in a CSH script. This morning I already had three
answers (two the same), so I'm posting this to hopefully stave
off a flood. The two answers were:

    1. Put the background stuff in a separate script, and redirect
       stdout from the shell.

    2. (better, IMHO)  Use parentheses to put the pipeline in a
       subshell (?), and put the '&' INSIDE the parentheses. Works
       like a charm! Ie, ( cat | awk | grep & ) instead of
       ( cat | awk | grep ) &.
    
    Thanks for all the fast responses...

       --- phelliax

-- 
wiml@blake.acs.washington.edu        (206)526-5885      Seattle, Washington

merlyn@iwarp.intel.com (Randal Schwartz) (11/19/89)

In article <4491@blake.acs.washington.edu>, wiml@blake (William Lewis) writes:
[that he wants to launch processes from csh without termination notify...]
|    Any help appreciated =8) (The FM for csh doesn't seem to say anything 
| about this...)

Right.  Cause the brain-dead csh was meant for *interactive* use, and
expects some human to *want* to know that the process got done.

Stuff

/bin/sh <\EOF
your process here &
EOF

into your .login.  If you need to have your process immune to SIGHUP,
SIGTERM, and the like, do something like:

/bin/sh <\EOF
trap '' 1 2 3 15
your process here &
EOF

Just another /bin/sh hacker,
-- 
/== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\
| on contract to Intel's iWarp project, Hillsboro, Oregon, USA, Sol III  |
| merlyn@iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn	         |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/