LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash shell script "sudo - (https://www.linuxquestions.org/questions/linux-newbie-8/bash-shell-script-sudo-641173/)

lunlun 05-09-2008 07:06 PM

bash shell script "sudo -
 
Hi there I got a question about the bash shell script and sudo.

Normally I would google for help, but then I dont know what am i supposed to search for.

e.g. i am under root user
Code:

sudo -u oracle sqlplus user/pass <createuser.sql

sudo -u oracle sqlplus user/pass <dosomething.sql

mkdir ./temp


my understanding is the sudo -u user let us execute a command on a specific user.

For my above scenario,

is there a way to modify my bash file so that upon the oracle user finishing its "sqlplus user/pass <createuser.sql" statement,

my bash file will continue to execute?


Thanks!

phantom_cyph 05-09-2008 07:17 PM

I'm assuming you aren't using some type of Ubuntu...

If you are running a shell script as the root user you will not need to put "sudo" in the script. Ubuntu disables the root account by default, restricting major changes to the local user's password.

The command "su" will prompt for the root password, and will allow you to do *most things. The command "su -" will actually switch you to the root account. And, assuming you have more than one user account, the command "su - whateverusername" will "log you in" (in the given shell) as that user.

eggixyz 05-09-2008 09:42 PM

Hey there,

Also make sure that (even though it's not necessary in certain circumstances) you make the sudo rule NOPASSWD: so that if, say, the oracle user has it in their .profile, it won't hang waiting on an interactive password entry!

Best wishes,

Mike


All times are GMT -5. The time now is 07:07 AM.