On 29 April 2014 15:20, ToddAndMargo <[email protected]> wrote:

> Hi All,
>
> I have a bash script that need to be run as root.
> In the script, I check to see if it is running as
> root and flag the user to run appropriately.
>
> Is there a way to use "su" to prompt for the password
> and continue the script if successful? (I would test for
> $? after the prompt.)
>
> Currently "su" will just open a new shell as root.
>
> I can run a command inside "su", but what about the
> other 200 lines of code?  :'(
>
>
The best you can do is run the script itself via su.. and that leads to all
kinds of interesting problems. Generally it is better to have the user type
the command themselves as root versus trying to be helpful inside of the
shell.




> Many thanks,
> -T
>
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>



-- 
Stephen J Smoogen.

Reply via email to