On Thu, Jan 08, 2004 at 02:44:38AM +0100, Florian Ernst wrote: > On Wed, Jan 07, 2004 at 07:13:44PM -0600, Rick Weinbender wrote: > >I have a situation where I login as the root user, > >then 'su <username>' to a user with limited rights, > >and run a short script as this user. > >* > >My question is: > >In the last line of my script, can I invoke some > >form of the exit command to leave me back > >at the #prompt or root user prompt? > > Better just run your script as > # su -c=<script> <username> > so you won't even get a user prompt to exit from. > > You could also use sudo... ... definitively; but if you really wanted to know how to do it the Wrong Way: Generally, as a Unix process exec's another one (a child), the child can't mess with the parent's internals more than with any other process'--they are just separated processes. The Unix way to terminate a process without its consent is to kill(8) it. So the last line of your script would read: kill -KILL "$PPID" --the shell variable $PPID stores the parent process id. AFAICT, it's a POSIX-required feature, so your sh(1) should provide it. Cheers, Jan. -- Jan Minar "Please don't CC me, I'm subscribed." x 9
Attachment:
pgpZ1oJM7vKff.pgp
Description: PGP signature