4 Replies Latest reply: May 31, 2014 8:10 AM by 1826067 RSS

    Connecting to a remote DB from inside a shell script


      Hi All,


      This is my first post here, so not sure if this is the correct community for this post.


      I want to be able to connect remotely to a database from a shell script and run some queries, however I'm unable to do so.


      Here is the code snippet being used:


      execute_dg ()





      sqlplus -s <<EOF |tee -a $LOGFILE


      set echo on

      set pages 0

      set heading off

      set lines 200






      return $?



      check_pre_fb ()




      lag=`execute_dg $prmy $paswd $query`


      info "Current Archive log gap between Primary & Standby is :$lag"

      echo "Please"


      enable_fb_sby ()


      echo "Enter Primary DB name" | tee -a $LOGFILE

      read prmy

      echo "Enter Sys password"  | tee -a $LOGFILE

      read -s pswd


      check_pre_fb $prmy $pswd



      The error while debugging is a s below:


      ++ user='sys/*******'

      ++ sqlplus -s '"sys/********"@prmy11' as sysdba

      ++ tee -a /sys_apps_01/ogg/testpre.log

      ++ return 0

      + lag='

      SP2-0306: Invalid option.

      Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM}] [edition=value]]

      where <logon> ::= <username>[/<password>][@<connect_identifier>]

            <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]'

      + info 'Current Archive log gap between Primary & Standby is :


      Any ideas?