Avatar of la_colibri
la_colibri

asked on 

I need the script to connect to a database using putty

Hi,
I am new to Putty and need to be able to connect to my database to reboot. Can you tell the syntax for connecting to the database? I have putty set up so I can log into the box. Thanks.

Shell ScriptingOracle Database

Avatar of undefined
Last Comment
Naveen Kumar
Avatar of Naveen Kumar
Naveen Kumar
Flag of India image

have the below contents in the shell script file run_free.sh
$ cat run_free.sh
echo "script started at : `date` "
sqlplus scott/tiger@testdb < have any valid sql statements in the free.sql which will be called from run_free.sh

To execute, you just need to say

$run_free.sh

Thanks
Avatar of la_colibri
la_colibri

ASKER

I am confused... I thought it was as simple as logging into the server via Putty then entering something along the lines of "sqlplus login//password@database_name" and then continue as if I were logged into SQLPLUS. Am I wrong?
Avatar of Naveen Kumar
Naveen Kumar
Flag of India image

i gave you the script which can do that automatically for you. i mean if you schedule that script through crontab in unix.

As you said, if you want to do it manually, login into putty using unix user name/password and hostname. once you are in the unix prompt, then sqlplus login/password@database_name will do and that will take you to SQL> prompt where in you can type all valid sql commands.
Avatar of la_colibri
la_colibri

ASKER

Understood... I received "ksh: sqlplus: not found" after trying manually.... any idea why I am getting this message?
Avatar of Naveen Kumar
Naveen Kumar
Flag of India image

your $PATH variable is not having the correct path. I mean shell is not able to find sqlplus executable in the directories listed in the PATH variable.

check with your UNIX system administrator if you do not have permission to modify the PATH variable settings or if you cannot locate where the sqlplus executable is there.

Usually it will be there in the bin directory of $ORACLE_HOME. For your understanding, in my unix server it is like as shown below

$ cd $ORACLE_HOME/bin
$ ls -lrt sqlplus
-rwxr-xr-x   1 oracle   dba        23847050 Mar 22 2007  sqlplus
Avatar of la_colibri
la_colibri

ASKER

what is the syntax to set the correct Path?
ASKER CERTIFIED SOLUTION
Avatar of Naveen Kumar
Naveen Kumar
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Naveen Kumar
Naveen Kumar
Flag of India image

Also if you do not want to set the PATH, you can even directly invoke that sqlplus by either of the below ways

cd $ORACLE_HOME/bin
./sqlplus username/password@testdb

or

$ORACLE_HOME/bin/sqlplus username/password@testdb
Oracle Database
Oracle Database

Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.

81K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo