I am trying the following using a shell script:
1. Login to a remote host through ssh ( I have alreay setup the public-private keys and it is working fine)
2. Fire a SQL query to get count of rows in a table, return that to a variable
This does not appear to work.
The problem is..it does not appear to run the commands within the backtick in the ssh session. This is because the error reported is about the path of sqlplus : "No such file or directory" (Oracle home is different in the local host and remote hosts) . Need help from shell scripting experts.
sqlquery=select count(*) from test;
ssh oracle@$192.168.1.2 "
$source_oracle_home/bin/sqlplus -s dbuser/dbpassword@MYDB << EOF
set heading off
set feedback off
echo Number of rows: $rowcount"