newgrp in shell programs

John Mundt john at chinet.chi.il.us
Sun Jul 23 02:54:44 AEST 1989


In article <127 at sdcc10.ucsd.EDU> bruno at sdcc10.ucsd.EDU (Bruce W. Mohler) writes:
>In article <124 at sdcc10.ucsd.EDU>, bruno at sdcc10.ucsd.EDU (Bruce W. Mohler) writes:
>> Is it possible to do a newgrp near the beginning of
>> a shell program (especially one that has been started by cron)?
>
>Thanks to Ihor Kinal and Paul Hite for providing me
>2 different answers to my problem.  The answer that
>best solves my problem is
> --> From: ijk at cbnewsh.ATT.COM (ihor.j.kinal)
> --> Here's one thing that comes to mind [I've tried it and it does work]"
> --> newgrp NEW_GROUP <<!
> --> shell script goes here
> --> !
> --> --------------------
> --> Of course, when you're done, you're logged off the machine


You really should't get logged off, but if it's a problem,  you can put 
the whole mess inside of a subshell so that you'll get your old prompt 
back afterwards:

(
 newgrp NEW_GROUP <<!
	 shell script goes here
 !
)

Probably could do an exec newgrp... and save a process as well.


-- 
---------------------
John Mundt   Teachers' Aide, Inc.  P.O. Box 1666  Highland Park, IL
john at chinet.chi.il.us
(312) 998-5007 (Day voice) || -432-8860 (Answer Mach) && -432-5386 Modem  



More information about the Comp.unix.questions mailing list