![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I need it to prompt me for a root password, so I don't have to log as root | lunchtime | UNIX for Dummies Questions & Answers | 2 | 06-25-2007 04:21 PM |
| how to access root priveliges if root password is lost | wojtyla | Linux | 1 | 02-18-2005 06:24 AM |
| Lost root password / Can't login as root | Perderabo | Answers to Frequently Asked Questions | 0 | 06-22-2004 08:40 PM |
| No root password | cyno | UNIX for Dummies Questions & Answers | 6 | 08-15-2002 01:57 AM |
| root password | silver40 | Shell Programming and Scripting | 9 | 03-21-2002 04:38 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
ask for root password
Hey all me again, what do i need to put in my script to check for root privalges and if not then ask for them, what ive got so far is, thankyou in advance for any help.
if [ $(whoami) = "root" ] then ????????????????????? then |
|
||||
|
Quote:
if [ $(whoami) != "root" ] ; then command else su root -c command fi the su will ask for a password. it would be a better idea to use sudo: if [ $(whoami) != "root" ] ; then /path/to/command else sudo /path/to/command fi sudo will ask for the password.. |
|
||||
|
Thank you for you reply, but i just cant get it to work, sudo is out of the question as
there is no sudo set up if i run below as root it prints hello, but if i run as non root it will ask for password then, nothing, what am i doing wrong plse, #!/bin/bash if [ $(whoami) = "root" ] then echo "hello" else su root -c echo "hello" fi |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|