1752795 Members
5753 Online
108789 Solutions
New Discussion юеВ

sudo

 
SOLVED
Go to solution
Mehmood Ansari
Frequent Advisor

sudo

Hi
I am using sudo on HP 11.11 and running fbackup within OPER menu i.e /usr/sbin/fbackup it is working fine. I want to shutdown oracle database with same command, but it is not working. I am getting massage:
$ /usr/local/bin/sudo -u oracle9 shutdown_PRIM.sql
/usr/local/bin/sudo: unable to exec shutdown_PRIM.sql: Permission denied
$ /usr/local/bin/sudo shutdown_PRIM.sql
./shutdown_PRIM.sql[3]: sqlplus: not found.

Please someone can help.

Regards
5 REPLIES 5
Peter Godron
Honored Contributor

Re: sudo

Hi,
have you chaecked the Unix permissions on the sql file.
Ensure that the PATH variable include the location of sqlplus ($ORACLE_HOME/bin)

Please close tread if resolved.
Regards
Bill Hassell
Honored Contributor

Re: sudo

The sudo command NEVER logs in like the oracle9 user. Instead, it simply starts the shutdown_PRIM.sql code. What is missing is the complete environment that is present when logging in as oracle9. Start by logging in as oracle9, then type the command:

set > oracle9.env

Now you have a picture of what the correct environment should be. oracle9.env then becomes the beginning of your script to run shutdown_PRIM.sql by having all the correct variables set. Or, you can look through /etc/profile and $HOME/.profile to see where Oracle-specific variables are setup and copy that into your script. Now your sudo command will run the script and not the sql code by itself. Be sure to read the details about Security in the sudo man pages where it talks about the environment.


Bill Hassell, sysadmin
Jannik
Honored Contributor
Solution

Re: sudo

I would something like this:
sudo su - oracle9 -c 'export ORACLE_SID=YOUR_SID; sqlplus /nolog @/path/to/your/file/shutdown_PRIM

And this sql file should look like this:
cat /path/to/your/file/shutdown_PRIM.sql
connect /as sysdba
shutdown immediate
exit

Or you could do:
sudo su - oracle9 "export ORACLE_SID=YOUR_SID; echo \"connect internal;\n shutdown immediate;\"|svrmgrl"
jaton
Mehmood Ansari
Frequent Advisor

Re: sudo

Hi

Thanks to all for assistance, I can shutdown and startup oracle database.

Mehmood
Mehmood Ansari
Frequent Advisor

Re: sudo

Hi
Thanks to Peter,Bill and Jannik to assistance, now I can shutdown and startup database and listner.

Regards and thanks to all.

Mehmood