[comp.unix.questions] Why won't scripts run in the background?

khera@juliet.cs.duke.edu (Vick Khera) (04/10/90)

In article <1990Apr9.212425.6452@aucs.uucp> 880139h@aucs.UUCP (Rob Hu10) writes:
>This has been bugging me for just about too long.  I've even asked 
>all the local smart fellers and none of them have any ideas.  So,
>I post my question:
>
>WHY WON'T ANY @$#%$!!! SHELL SCRIPTS RUN IN THE BACKGROUND SUCCESFULLY
>ON MY ACCOUNT WHEN THE _SAME_ SCRIPTS RUN JUST DANDY IN OTHER FOLK'S
>ACCOUNTS????!!!!!
>
>If I set up a script to run in the background, eg. scriptname &,
>it runs just fine until I type a command or just <return>.  The error
>message I get is :
>
>[1] +Stopped  (tty output)  scriptname
>
>Or some such thing.
>
>I'm runing SunOS on a Sun4.  I've included my .cshrc file incase it's
>something in there.  Anyone have any ideas?  PLEEEEEEEEAAASE?
>Thank you very much.
>------  my .cshrc -------
> [ ... ]
>
>stty erase ^H
> [ ... ]

this is the culprit.  stty wants to output information to your tty but
can't.  something like the following at the start of your .cshrc file
should help. also, you may wish to make sure your shell script start with

#!/bin/csh -f

so your .cshrc file is not executed anyway.
place this at the top of your .cshrc file:

# if non-interactive, do not set up aliases, etc., but set path.
if ($?prompt == 0) then
	umask 022
	source ~/.setpath
	exit
endif


>Rob Hutten : 880139h@aucs.uucp      542-1686/678-7088  Wolfville, NS, Canada
			   ^^^^ get a more useful address. i can't mail
directly to you using this one (which i would have preferred in this case).

								v.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vick Khera           (919) 660-6528     Department of Computer Science
ARPA:   khera@cs.duke.edu               Duke University
UUCP:   ..!{mcnc,decvax}!duke!khera     Durham, NC 27706

schriste@uceng.UC.EDU (Steven V. Christensen) (04/10/90)

880139h@aucs.uucp (Rob Hu10) writes:


>This has been bugging me for just about too long.  I've even asked 
>all the local smart fellers and none of them have any ideas.  So,
>I post my question:

>WHY WON'T ANY @$#%$!!! SHELL SCRIPTS RUN IN THE BACKGROUND SUCCESFULLY
>ON MY ACCOUNT WHEN THE _SAME_ SCRIPTS RUN JUST DANDY IN OTHER FOLK'S
>ACCOUNTS????!!!!!

>If I set up a script to run in the background, eg. scriptname &,
>it runs just fine until I type a command or just <return>.  The error
>message I get is :

>[1] +Stopped  (tty output)  scriptname

You need to have in your .login file the following command:

	stty -tostop

This tells the system not to stop background programs when they try
to write to the stdout.

see also: man stty


		Steven
-- 
Steven V. Christensen
U.C. College of Eng.
schriste@uceng.uc.edu