fi unexpected


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting fi unexpected
# 1  
Old 07-10-2010
fi unexpected

Hi gurus,

I wrote the below script which finds the process ids and if there is a change b/w previous process id and the current value, it sends out a email notification to the users. When I try to execute the below code, i am getting the following error

server_mon.ksh: line 51: syntax error at line 81: `fi' unexpected

Code:

#!/bin/ksh
set ORACLE_HOME=/oracle/product/10.2/bin
export ORACLE_HOME
LOGON=`cat apps/int/ctrl/orcl_schema.txt`
HOSTNAME=`hostname -s`
# check for hostname entry in INFA_PROCESS table
`sqlplus -s $LOGON << EOF
SET SERVEROUT ON
SET FEEDBACK OFF
SET HEADING OFF
SET TIMING OFF
SET TERMOUT OFF
SET LINES 160
DECLARE
 v_host_name    VARCHAR2(30);
BEGIN
    SELECT host_name
    INTO   v_host_name
    FROM INFA_PROCESS
    WHERE host_name = '${HOSTNAME}';
END;
/
SET SERVEROUT OFF
exit
EOF`
echo $RC
RC=$?
if [ $RC -eq 0 ] ; then
        echo "Successfully selected the entry for ${HOSTNAME}in INFA_PROCESS table."
  else
        exit 1
 fi

 # Query INFA_PROCESS table for previous values of PMSERVER_PRC_ID and DOMAIN_PRC_ID in INFA_PROCESS table.
 eval `sqlplus -s $LOGON << !
 SET FEEDBACK OFF
 SET HEADING OFF
 SET TIMING OFF
 SET TERMOUT OFF
 SET LINES 160
 SELECT 'export prev_PMSERVER_PRC_ID="' || PMSERVER_PRC_ID || '";' FROM INFA_PROCESS WHERE HOST_NAME = '${HOSTNAME}'
 UNION
 SELECT 'export prev_DOMAIN_PRC_ID="' || NVL(DOMAIN_PRC_ID,0) || '";' FROM INFA_PROCESS WHERE HOST_NAME = '${HOSTNAME}';
 !`

     #RC=$?
     #       if [ $RC -ne 0 ] ; then
     #           echo "$0: ERROR! while retrieving the previous PMSERVER_PRC_ID and DOMAIN_PRC_ID for ${HOSTNAME}."
     #          exit 1
     #       fi
 echo "Previous PMSERV PRC ID="$prev_PMSERVER_PRC_ID
 if [$prev_PMSERVER_PRC_ID -eq 0 -o $prev_DOMAIN_PRC_ID -eq 0]; then

 PMSERVER_PRC_ID=`ps -fu inform | grep 'pmserver' |sed -n '1p'|awk '{print $2}'`
 DOMAIN_PRC_ID=`ps -fu inform | grep 'domain' |sed -n '1p'|awk '{print $2}'`
 echo " PMSERVER_PRC_ID= "$PMSERVER_PRC_ID
 eval `sqlplus -s $LOGON << !
  SET FEEDBACK OFF
  SET HEADING OFF
  SET FEEDBACK OFF
  SET HEADING OFF
  SET TIMING OFF
  SET TERMOUT OFF
  SET LINES 160
  UPDATE INFA_PROCESS SET PMSERVER_PRC_ID = '${PMSERVER_PRC_ID}', DOMAIN_PRC_ID = '${DOMAIN_PRC_ID}' WHERE HOST_NAME = '${HOSTNAME}';
  SET SERVEROUT OFF
  exit
  EOF`
  echo $RC
  RC=$?
  if [ $RC -eq 0 ] ; then
          echo "Successfully updated PMSERVER_PRC_ID and DOMAIN_PRC_ID for ${HOSTNAME} in INFA_PROCESS table."
    else
          exit 1
  fi
 else
    if [ $prev_PMSERVER_PRC_ID -ne $PMSERVER_PRC_ID -o $prev_DOMAIN_PRC_ID -ne $DOMAIN_PRC_ID -a ! -e /apps/int/scripts/file_watch.txt]
          touch /apps/int/scripts/file_watch.txt
          uuencode server_mon.log server_mon.log | mailx -s "FAILURE" "xxxx@domain.com"
    fi
  fi

Please help me on this.

Last edited by svajhala; 07-10-2010 at 10:32 AM..
# 2  
Old 07-10-2010
Hi
Missing then in the below if:


Code:
if [ $prev_PMSERVER_PRC_ID -ne $PMSERVER_PRC_ID -o $prev_DOMAIN_PRC_ID -ne $DOMAIN_PRC_ID -a ! -e /apps/informatica/scripts/file_watch.txt];then
          touch /apps/informatica/scripts/file_watch.txt

Guru.
# 3  
Old 07-10-2010
Great! thats awesome.. that issue is fixed but now i am getting another error


monitor_infa_server_v2.ksh[52]: [0: not found [No such file or directory]
monitor_infa_server_v2.ksh[77]: [: ']' missing
# 4  
Old 07-10-2010
Hi
The syntax of 'if' is :

Code:
  if [ $x -eq 0 ]

Please note there is a blank space after "[" and before "]" in the example above. However, this is not followed in quite a few places in your code.

Guru.
This User Gave Thanks to guruprasadpr For This Post:
# 5  
Old 07-10-2010
Hi Guru.. You are a real Guru Smilie It works now
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

eof unexpected while looking[...]

Hello I use opensuse build service to build packages (oh surprise !) I have integrate a command in a spec whose worked and now this exit with: unexpected EOF while looking for matching `"' Command: if \.").mk ]; then ln -s $(pwd)/mozilla/security/coreconf/Linux2.6.mk \ ... (5 Replies)
Discussion started by: posophe
5 Replies

2. Shell Programming and Scripting

Getting unexpected error

Hi All, I am writing one script to automate one of the process and for that I am using below command at one line : uncompress `cat tmp` content in tmp file are : /home/vas/aqbatch/newbatch/archive/output/RIM_GUIDEPRICE_AQ_02108.DAT.Z... (5 Replies)
Discussion started by: NirajThakar
5 Replies

3. UNIX for Dummies Questions & Answers

unexpected EOF

hello everyone...im having this problem with unexpected EOF with line 85 which is..i cant see whats wrong with it..can any1 plz help me out. read -p "$p1 please enter the number of tries you wish to have:" lifeline function main() { guessnum=0 read -p "Please enter if its sinle player game... (1 Reply)
Discussion started by: Freakhan
1 Replies

4. Solaris

Unexpected df behavior

Hi, I have Sun SPARC Enterprise T5140 with two 2,5" 15rpm 146GB SAS HDD. In friday there were a lot of errors with fs on them. After reconfiguring all seemed to be fine but today I get the following strange behavior of df -kh command and troubles with files, I written on first disk in friday.... (9 Replies)
Discussion started by: Sapfeer
9 Replies

5. Shell Programming and Scripting

done' unexpected and do' unmatched

Good morning, I have been teaching myself shell scripting and seem to be stuck here. I am sure I am just blind and not seeing it so I thought maybe some fresh eyes would help. With the script below I keep getting.... "syntax error at line 248 : `done' unexpected" I am not seeing why this... (6 Replies)
Discussion started by: LRoberts
6 Replies

6. Solaris

Unexpected error

When I typed #svcs -x sma I received this following error, svcs: svcs.c:335: Unexpected libscf error: invalid argument. Exiting. I have googled around but could not find a solution. IS this a bug? I am using Solaris 5.10 Generic_137137-09 sun4v sparc... (2 Replies)
Discussion started by: sundar63
2 Replies

7. UNIX for Dummies Questions & Answers

unexpected error

./sample.5: syntax error: `(' unexpected I get this error and Im trying to solve it but the line that it refering to is a notation so I don't understand why it is affecting the program. (2 Replies)
Discussion started by: helpme2008
2 Replies

8. UNIX for Advanced & Expert Users

unexpected EOF

I ran the following scripts and everytime i get the errot as follows Line 54: unexpected EOF while looking for matching ',' line 57 syntex error unexpected end of file#!/bin/ksh set -x BKUP_DIR=/u03/backups/abu/nightly_backup LOG_FILE=/u03/backups/abu/backup.log ORACLE_HOME=... (9 Replies)
Discussion started by: manna
9 Replies

9. UNIX for Dummies Questions & Answers

Unexpected Results

Hello, When I run this script, here's what I get: Searching ... found 1111 2222 3333 ..... 7777 ..... 8888 9999 in 95_test Search completed. I expected only to see what number was found in the file, not including the ones not found. Thanks for your help! #!/bin/sh (1 Reply)
Discussion started by: SSims
1 Replies

10. HP-UX

unexpected exit

On top of that, there is another question met on HP-UX 11i v2. The running program exit unnormally and no coredump. I used the 'gdb' tool to debug , it exit and return the message: (gdb) ttrace wait: No child processes. When using 'where' to find the breakpoint, it retruned... (0 Replies)
Discussion started by: Frank2004
0 Replies
Login or Register to Ask a Question