Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 578
  • Last Modified:

Linux script using sqlplus

I have a very simple linux script using bash that's trying to call sqlplus.  If I hard code the user/pwd@sid, it works correctly.  But if I try to use variables as below, the connect fails.  How should I be passing the variable to the sqlplus command?

USER=ABC
PWD=123
SID=XYZ
sqlplus "${USER}/${PWD}@{SID}" <<! >./output.txt
  select count(*) from ACCOUNT;
exit

0
jkavx
Asked:
jkavx
1 Solution
 
jeremycrussellCommented:
Perhaps it's failing becuase {SID} is missing the $ sign?

sqlplus "${USER}/${PWD}@${SID}" <<! >./output.txt
0
 
farzanjCommented:
It works for me like this
sqlplus -S -l $USER/$PWD@$DATABASE << EOF
SET LIN 300;
SET HEADING OFF;
SET ECHO OFF;
SELECT COUNT(*) FROM ACCOUNT;
EXIT
EOF

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now