Saturday, February 2, 2013

Remote sqlplus Over SSH

Links to this post
Example is to show how to run sqlplus over ssh.

/usr/bin/ssh -qn catdummyxyz 'ORACLE_HOME=/u00/app/oracle/product/10.2.0/DB;export ORACLE_HOME;$ORACLE_HOME/bin/sqlplus -s sys/dummy@ASM as sysdba << EndOfFile
select dummy from dual;
select instance_number ,INSTANCE_NAME from v\$instance;
exit;
EndOfFile'

You can also export ORACLE_SID if you want.
/usr/bin/ssh -qn catdummxyz 'ORACLE_SID=+ASM2;export ORACLE_SID;ORACLE_HOME=/u00/app/oracle/product/10.2.0/DB;export ORACLE_HOME;$ORACLE_HOME/bin/sqlplus -s sys/dummy@ASM as sysdba << EndOfFile
select dummy from dual;
select instance_number ,INSTANCE_NAME from v\$instance;
exit;
EndOfFile'