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"

0 comments:

Post a Comment