matrix0511
asked on
How Can I Start SQLPLUS from Linux Command Line?
I have a linux server that i'm connecting to. It doesn't have the Oracle DB on this server but it does have the Oracle client. we are having some issues with this server connecting to a table in the Oracle DB on another server. So i need to test the this sever can access a table from sqlplus command line.
How can I start sqlplus from the command line to test this connection? what command do i use? Please provide the entire command..user ID, password, SID, etc.
Thanks!
How can I start sqlplus from the command line to test this connection? what command do i use? Please provide the entire command..user ID, password, SID, etc.
Thanks!
sqlplus username/password@yourdata basename
this does assume sqlplus is in your path.
If it is not, then you need to add
$ORACLE_HOME/bin
to your path
$ORACLE_HOME is wherever you installed the client
If it is not, then you need to add
$ORACLE_HOME/bin
to your path
$ORACLE_HOME is wherever you installed the client
First, you'll have to find out the installation directory of the client nad put tis int a variable $ORACLE_HOME.
Next, add $ORACLE_HOME/bin to your PATH.
Edit tnsnames.ora in $ORACLE_HOME/network/admin to connect a service name with the SID and the hostname of the remote DB.
A typical entry looks like this:
service =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
)
(CONNECT_DATA =
(SID = sid)
)
)
Then start sqlplus with:
sqlplus user/password@service
That's all.
wmp
Next, add $ORACLE_HOME/bin to your PATH.
Edit tnsnames.ora in $ORACLE_HOME/network/admin
A typical entry looks like this:
service =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
)
(CONNECT_DATA =
(SID = sid)
)
)
Then start sqlplus with:
sqlplus user/password@service
That's all.
wmp
ASKER
Guys, when you say I need to add "$ORACLE_HOME/bin" to my PATH, are you just talking about me "cd" to the "bin" dir on my Linux server and running "sqlplus" from bin?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
... at least you need $ORACLE_HOME by all means!
/apps/oracle/product/10.1. 3.1/bin/sq lplus
or
export PATH=$PATH:/apps/oracle/pr oduct/10.1 .3.1/bin
sqlplus
or
export PATH=$PATH:/apps/oracle/pr
sqlplus
The current directory is not in your PATH.
./sqlplus should work, but as I said, you need $ORACLE_HOME!
./sqlplus should work, but as I said, you need $ORACLE_HOME!
ASKER
@woolmilkporc, I understand what your saying about adding those lines to my .profile. However, this is how I connect to this Linux server.
I first login with my user ID (jburch). Then because all the oracle client install is owned by user: oracle i have to "sudo" to oracle. so then I am actually now logged in as oracle.
But I am not able to find the .profile for oracle under /home like the other accounts
So i'm not sure if i should be adding those $ORACLE_HOME paths to MY ID .profile or oracle .profile.
Also, I'm not sure if I will have access to edit this file. should i have access??
I first login with my user ID (jburch). Then because all the oracle client install is owned by user: oracle i have to "sudo" to oracle. so then I am actually now logged in as oracle.
But I am not able to find the .profile for oracle under /home like the other accounts
So i'm not sure if i should be adding those $ORACLE_HOME paths to MY ID .profile or oracle .profile.
Also, I'm not sure if I will have access to edit this file. should i have access??
ASKER
This is an example of what my .profile looks like on "another" linux server.
But for some reason I can't find a .profile for either my personal ID or "oracle" user.
what's the command to search for a file? I'll see if I can find it that way.
PATH=/usr/bin:/etc:/usr/sb in:/usr/uc b:$HOME/bi n:/usr/bin /X11:/sbin :.
export PATH
if [ -s "$MAIL" ] # This is at Shell startup. In normal
then echo "$MAILMSG" # operation, the Shell checks
fi # periodically.
But for some reason I can't find a .profile for either my personal ID or "oracle" user.
what's the command to search for a file? I'll see if I can find it that way.
PATH=/usr/bin:/etc:/usr/sb
export PATH
if [ -s "$MAIL" ] # This is at Shell startup. In normal
then echo "$MAILMSG" # operation, the Shell checks
fi # periodically.
are you using .bashrc instead of .profile ?
or .bash_profile ?
or .bash_profile ?
You need the envrionment configured for the user that you want to have run sqlplus.
.profile os technically 'optional'. If it doesn't exist and you do not know what 'rc' script you are using, create a .profile in the home directory:
cd ~
vi .profile
.profile os technically 'optional'. If it doesn't exist and you do not know what 'rc' script you are using, create a .profile in the home directory:
cd ~
vi .profile
sudo leaves you in your own environment, unless you perform a "sudo su -"
So if you just use to type
sudo -u oracle sqlplus ...
it's your own environment which counts.
But if you use
sudo su - oracle
sqlplus
you will have to create a .profile in oracle's $HOME to contain my 2 statements.
As an alternative you could of course always export ORCALE_HOME manually,
or run everything (including sqlplus) from a script.
or source a file containing just the two vatrables before typing sqlplus on the command line ...
Anyway, you need ORACLE_HOME as an exported variable, because it's the base for all message catalogs, the path to tnsnames.ora and much more.
wmp
So if you just use to type
sudo -u oracle sqlplus ...
it's your own environment which counts.
But if you use
sudo su - oracle
sqlplus
you will have to create a .profile in oracle's $HOME to contain my 2 statements.
As an alternative you could of course always export ORCALE_HOME manually,
or run everything (including sqlplus) from a script.
or source a file containing just the two vatrables before typing sqlplus on the command line ...
Anyway, you need ORACLE_HOME as an exported variable, because it's the base for all message catalogs, the path to tnsnames.ora and much more.
wmp
or .bash_login?
.profile is last in the bash startup search
.profile is last in the bash startup search
ASKER
I think part of this issue might be that I'm not running this from the correct location. Does anyone know under ORACLE_HOME where I go from there to find the script or program to run sqlplus?
How are you using sudo normally?
What you entered is wrong anyway.
Either you go:
sudo -u oracle sqlplus
(start sqlplus with oracle's privileges)
or
sudo su - oracle
(switch to user oracle, starting a login shell under the oracle account, to start sqlplus or anything else afterwards).
Find out what you're allowed to so with sudo with
sudo -l
(as jburch)
What you entered is wrong anyway.
Either you go:
sudo -u oracle sqlplus
(start sqlplus with oracle's privileges)
or
sudo su - oracle
(switch to user oracle, starting a login shell under the oracle account, to start sqlplus or anything else afterwards).
Find out what you're allowed to so with sudo with
sudo -l
(as jburch)
>> Does anyone know under ORACLE_HOME where I go from there to find the script or program to run sqlplus? <<
sqlplus is in $ORACLE_HOME/bin, but that's NOT part of the issue. as soon as you set the PATH correctly as I mentioned.
sqlplus is in $ORACLE_HOME/bin, but that's NOT part of the issue. as soon as you set the PATH correctly as I mentioned.
Three choices
either cd to $ORACLE_HOME/bin and use "./sqlplus" - this means execute from current directory regardless of your path
OR
add "." to your path and cd to $ORACLE_BIN and use "sqlplus" -- letting the path figure out your current directory
OR
add $ORACLE_HOME/bin to your path and use "sqlplus" from any directory -- letting the path know exactly where to find sqlplus
either cd to $ORACLE_HOME/bin and use "./sqlplus" - this means execute from current directory regardless of your path
OR
add "." to your path and cd to $ORACLE_BIN and use "sqlplus" -- letting the path figure out your current directory
OR
add $ORACLE_HOME/bin to your path and use "sqlplus" from any directory -- letting the path know exactly where to find sqlplus
ASKER
@woolmilkporc, ok, I went back and ran that sudo command you mentioned. See the results below.
I have a question for you. Since I can't find the .profile i need to update the path with, is it possible that I could just enter the paths below "manually" from the command line? would that not then give me the ability to run "sqlplus" from the /OracleAS_1/bin ?
I don't know if that's possible but I'm just asking.
export ORACLE_HOME=/path/to/insta ll/dir
export PATH=$PATH:$ORACLE_HOME/bi n
I have a question for you. Since I can't find the .profile i need to update the path with, is it possible that I could just enter the paths below "manually" from the command line? would that not then give me the ability to run "sqlplus" from the /OracleAS_1/bin ?
I don't know if that's possible but I'm just asking.
export ORACLE_HOME=/path/to/insta
export PATH=$PATH:$ORACLE_HOME/bi
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can enter everything manually, but after "sudo su - oracle"
although I'm a bit astonished that "oracle" doesn't have this set up already.
although I'm a bit astonished that "oracle" doesn't have this set up already.
ASKER
please stop posting images of screen shots. It makes it difficult for us to reference individual lines without retyping everything.
You are still trying to mix and match. If everything in the environment is set up properly, no need to 'cd' into anything.
Where did you install the client? Is it under the OracleAS_1?
If so:
export ORACLE_HOME=/apps/oracle/p roduct/10. 1.3.1/Orac leAS_1
export PATH=$PATH:$ORACLE_HOME/bi n
sqlplus
You are still trying to mix and match. If everything in the environment is set up properly, no need to 'cd' into anything.
Where did you install the client? Is it under the OracleAS_1?
If so:
export ORACLE_HOME=/apps/oracle/p
export PATH=$PATH:$ORACLE_HOME/bi
sqlplus
are you sure you have sqlplus installed?
what does this return?
as slightwv suggested, please do not send a screen capture.
Everything you're doing is text, just copy and past the text.
what does this return?
ls /apps/oracle/product/10.1.3.1/bin/sqlplus
as slightwv suggested, please do not send a screen capture.
Everything you're doing is text, just copy and past the text.
ASKER
Thanks. I'm good now. appreciate the effort.