How to solve this problem in shell script: unexpected end of file

Hello

I need to connect to each of the databases listed in/etc/oratab and check what database is stopped (or mounted only) and what database is opened to accept the connection. However, the following shell script gives me this error message:

$>./check_is_db_runing.sh
. / check_is_db_runing.sh: line 39: syntax error: unexpected end of file

Could someone please help me solve this problem, why the code (line 29 to 32) does not work in the LOOP? It works without the LOOP.

Thanks in advance!



1 #! / bin/bash
2
3 LOGDIR = / oracle/data03/dbscripts
4 ORATABFILE = / etc/oratab
5
6 cat $ORATABFILE | read everything online
7 do
8-case $LINE in
9 \#*) ;; Comment # line in oratab
10 *)
11 ORACLE_SID ='echo $LINE | AWK - f: '{print $1}'-'
12 if ['$ORACLE_SID' = ' *']; then
13 # NULL SID - ignore
14 ORACLE_SID =""
continue 15
16 IFS
17
# 18 continue only if the last field corresponds to 'Y '.
19 if ["' echo $LINE | '] [' awk - f: '{print $NF}'-' "="Y"]; then
20 if [' echo $ORACLE_SID | cut b 1'! = '+']; then
21
22 ORACLE_HOME ='echo $LINE | AWK - f: '{print $2}'-'
23 PATH = $ORACLE_HOME/bin: / bin: / usr/bin: / etc
24 export ORACLE_HOME ORACLE_SID, PATH
LOGFILE = $25 LOGDIR/check_$ ORACLE_SID.log
26 touch $LOGFILE
#echo 27 $LOGFILE
28
$29 ORACLE_HOME/bin/sqlplus - s "/ as sysdba" < < EOF > $LOGFILE
30 select * from global_name;
exit 31
32 EOF
33
34 fi
35 fi
36;
ESAC 37
38 fact

This code works IE. produces newspapers with result sql - slightly modified to be executable:

#! / bin/bash

LOGDIR = / tmp
ORATABFILE = / etc/oratab

Cat $ORATABFILE | read everything online
do
case $LINE in
\#*) ;; Comment # line in oratab
*)
ORACLE_SID ='echo $LINE | AWK - f: '{print $1}'-'
If------[-z $ORACLE_SID-]; then
# NULL SID - ignore
ORACLE_SID =""
continue

# Only if the last field corresponds to 'Y '.
on the other

ORACLE_HOME ='echo $LINE | AWK - f: '{print $2}'-'
PATH = $ORACLE_HOME/bin: / bin: / usr/bin: / etc
export ORACLE_HOME ORACLE_SID, PATH
LOGFILE = $logdir/check_$ ORACLE_SID.log
Touch $LOGFILE
#echo $LOGFILE

$ORACLE_HOME/bin/sqlplus - s "/ as sysdba" < eof=""> $LOGFILE
Select * from global_name;
output
EXPRESSIONS OF FOLKLORE

FI
;;
ESAC
fact

Tags: Database

Similar Questions

Maybe you are looking for