1 Reply Latest reply on May 18, 2007 9:27 AM by Paul M.

    error in shell script

    511922
      Hi,

      I have written a small shell script which logs into each oracle database on the server and displays whether it is in archivelog mode or not.. The script is as under:


      #!/bin/bash
      dblist=`ps -ef | grep smon | grep -v grep |cut -d'_' -f3`
      for ohome in $dblist; do
      sqlplus -s /nolog << EOF
      connect / as sysdba ;
      ORACLE_SID=$ohome; export ORACLE_SID
      set heading off
      set feedback off
      set verify off
      output=`select log_mode from v$database;`
      exit;
      EOF
      echo $ohome
      echo $output | sort -u
      done

      When I run it .. i received errors as under:

      jalpan.sh: select: not found
      Connected.
      SP2-0734: unknown command beginning "ORACLE_SID..." - rest of line ignored.
      SP2-0042: unknown command "output=" - rest of line ignored.
      bnkdbp01

      jalpan.sh: select: not found
      Connected.
      SP2-0734: unknown command beginning "ORACLE_SID..." - rest of line ignored.
      SP2-0042: unknown command "output=" - rest of line ignored.
      dosdbp01 --> Oracle Database Name

      Pls help

      Thx in advance

      PS: I an new to unix env.. but i do now basics..
        • 1. Re: error in shell script
          Paul M.
          Try this way:
          jalpan.log
          dblist=`ps -ef | grep smon | grep -v grep |cut -d'_' -f3`
          for ohome in $dblist; do
                  ORACLE_SID=$ohome; export ORACLE_SID
                  output=`sqlplus -s "/ as sysdba" << EOF
                  set heading off
                  set feedback off
                  set verify off
                  select log_mode from v\\$database;
                  exit;
                  EOF`
                  echo $ohome $output >>jalpan.log
          done
          sort jalpan.log