Home » Infrastructure » Linux » sudo sqlplus -v returns "Error 6 initializing SQL*Plus" (oracle 11g on centos 7)
sudo sqlplus -v returns "Error 6 initializing SQL*Plus" [message #665851] Tue, 26 September 2017 05:15 Go to next message
snuggiebear
Messages: 2
Registered: September 2017
Junior Member
I am needing to run sqlplus -v on Linux where the user I am connecting with does not have execute permission on sqlplus.

I can however set what I need up my users profile as well as sudoers.

I have set in sudoers:

user1 ALL=(oracle) NOPASSWD: /u01/app/oracle/product/11.2.0/dbhome_1/bin/sqlplus

I then login with user1 and execute:
export ORACLE_SID=wujjii
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_BASE=/u01/app/oracle
export PATH=$PATH:$ORACLE_HOME/bin
And finally:
sudo -u oracle /u01/app/oracle/product/11.2.0/dbhome_1/bin/sqlplus -v
This does not prompt for password however returns:

Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory


I know this is an age old topic but I think I have covered the basics here so any help appreciated.
Re: sudo sqlplus -v returns "Error 6 initializing SQL*Plus" [message #665855 is a reply to message #665851] Tue, 26 September 2017 07:02 Go to previous messageGo to next message
BlackSwan
Messages: 25742
Registered: January 2009
Location: SoCal
Senior Member
I know what the problem is.
I am just not sure what needs to be done to correct it.

For debugging purposes change the sudo line to be as below

sudo -u oracle env > /tmp/capture.env

then post content of /tmp/capture.env back here
Re: sudo sqlplus -v returns "Error 6 initializing SQL*Plus" [message #665856 is a reply to message #665851] Tue, 26 September 2017 07:06 Go to previous messageGo to next message
John Watson
Messages: 7180
Registered: January 2010
Location: Global Village
Senior Member
This works for me, but it may be very shell specific:
[ec2-user@ip-172-30-0-72 ~]$
[ec2-user@ip-172-30-0-72 ~]$ sudo -u oracle -- sh -c 'export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1;/u01/app/oracle/product/12.2.0/dbhome_1/bin/sqlplus -v'

SQL*Plus: Release 12.2.0.1.0 Production

[ec2-user@ip-172-30-0-72 ~]$
Re: sudo sqlplus -v returns "Error 6 initializing SQL*Plus" [message #665857 is a reply to message #665856] Tue, 26 September 2017 07:23 Go to previous message
snuggiebear
Messages: 2
Registered: September 2017
Junior Member
John Watson wrote on Tue, 26 September 2017 07:06
This works for me, but it may be very shell specific:
[ec2-user@ip-172-30-0-72 ~]$
[ec2-user@ip-172-30-0-72 ~]$ sudo -u oracle -- sh -c 'export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1;/u01/app/oracle/product/12.2.0/dbhome_1/bin/sqlplus -v'

SQL*Plus: Release 12.2.0.1.0 Production

[ec2-user@ip-172-30-0-72 ~]$
Thanks John. I can get this working with the following in sudoers:

user1 ALL=(oracle) NOPASSWD: ALL

Would you know the discrete sudoers definition to run just the required command ? Appreciate this is diverging from Oracle itself.
Previous Topic: df command insert into sqlplus and table databas
Next Topic: Oracle Client on Virtual System
Goto Forum:
  


Current Time: Tue Dec 12 09:30:29 CST 2017

Total time taken to generate the page: 0.02528 seconds