home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.admin:4375 comp.unix.shell:3199 comp.unix.questions:9566
- Newsgroups: comp.unix.admin,comp.unix.shell,comp.unix.questions
- Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbfsb!cbnewsg.cb.att.com!cooper
- From: cooper@cbnewsg.cb.att.com (Ralph 'Hairy' Moonen)
- Subject: Re: Logging in as root within a shell script
- Message-ID: <1992Jul30.075910.5793@cbfsb.cb.att.com>
- Followup-To: comp.unix.questions
- Sender: news@cbfsb.cb.att.com
- Organization: AT&T
- References: <trung.712443864@sundance>
- Date: Thu, 30 Jul 1992 07:59:10 GMT
- Lines: 28
-
- In article <trung.712443864@sundance>, trung@sundance.SJSU.EDU (Trung Tran) writes:
- > I would like to run a shell script which will ask me for the root's password
- > before allowing me to do some other administrative tasks. Once a correct
- > password is entered, the script will go on executing the next command
- > (instead of starting a root shell). When all tasks are done, it will
- > automatically log out of root shell and continue with the rest of the
- > script. Can someone please tell me if this is possible to achieve. If so,
- > how can it be done? Or is it too risky?
-
- It's allways risky, but OK, here goes:
-
- # first part of script here, say start up things, etc....
- # next you want to do things in root
- su root <<EOF!
- # place commands to be executed under root here
- EOF!
- # place more normal commands here...
-
- This will prompt for the root password, and only continue after the
- password has been entered. If an incorrect password is given, the script
- just continues execution of the commands that occur after the EOF! line.
-
- --Ralph Moonen
- --
- begin 644 ralph.pub
- MF58 ]M2*@QR86QP:%]M;V]N96[^ 6- RJ-V"2/)B4[K']_ZR@4#IVQE=TT6
- LHD.M[5JN9O_E1]Z9HXM/%A$WW.E[OA8>ES0S+;I@Q::BY.J8/Z]22#4% !$6
- end
-