Below script helps me to ssh and do sqlplus to fetch info from database. I checked and it worked well but the only problem is if i use single quotes in the sql query then I am getting an error since I already used single quotes for ssh.
db_info=`${ssh_path} -qn ${ssh_host} '
DBHost="<TNS>";
$ORACLE_HOME/bin/sqlplus -s $DBUser/$DBPass@$DBHost <<EOF
set heading off feedback off verify off
Select count(*) from table_name where column = 'hell123';
quit;
EOF
'`
echo $db_info
$()
construct. – ott-- Jan 06 '16 at 16:25echo 'Like '\'' This'
– thrig Jan 06 '16 at 17:18