Bash: Connect to Oracle DB

Even you dont have tnsora defined for your database , you can still connect to database using below shell script.

LOGIN_DATA="user/password@'
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=XXX.XXX.XXX.XXX)(PORT=1521))
(CONNECT_DATA=(SID=SID)))'"
CONNECT=`sqlplus -S ${LOGIN_DATA} <<- span="">EOF
SET ECHO OFF;
select count(*) from table;
EOF`

echo "$CONNECT"

Comments

Popular posts from this blog

grep: unknown device method

Uploading files to FTP/SFTP using CURL

How to find outgoing IP in Linux ?