Script giving error-Unable to identfiy

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script giving error-Unable to identfiy
# 8  
Old 12-17-2013
I have posted the entire script before your post.Please review.


Best regards,
# 9  
Old 12-17-2013
I cannot reproduce the (-error in your script, but you have several other problems:

Line 69 should not end with ;;

Line 79 should not begin with a $

After line 79, esac is required to end the case statement.

---------- Post updated at 15:12 ---------- Previous update was at 15:11 ----------

Or line 69 is ok, then esac is needed after line 69.
# 10  
Old 12-17-2013
Hello Vishal,

Not sure but seems you may need to close the case with
esac. Please try to do the same.

R. Singh
# 11  
Old 12-17-2013
I have done the corrections -it's still giving error .Please see the update code

#set -x
while getopts ":n:t:" opt; do
    case "$opt" in
if ping -c 2 $host >/dev/null 2>&1
    echo Host OK
    echo Bad Host $host
case "$targ" in
    pref|avail) echo targ OK;;
    *)    echo Bad argument to -t;;
echo "host = $host targ = $targ"
declare -a lines
  declare -a pref
  declare -a avail

  lines=`srvctl config service -d ${1} -s ${2}|egrep '^(Preferred|Available) instances:'`;
  for ((i=0;i<${#lines[@]};i++))
    if [ "${line:0:21}" = 'Preferred instances: ' ]; then
      pref=($(echo "${line:21}"|sed 's/,/\n/g'));
      avail=($(echo "${line:21}"|sed 's/,/\n/g'));
  # array with preferred instances
  for ((m=0;m<${#pref[@]};m++))
    echo " ${pref[$m]} "
  # array with available instances
  for ((m=0;m<${#avail[@]};m++))
     echo " ${avail[$m]} "
export CRS_HOME=/devoragridcn_01/Grid_11203
for database in `$CRS_HOME/bin/crsctl status res -n $host| grep -E "ora.*\.db" | awk -F"." '{print $(NF-1)}'`
export ORACLE_HOME=`$CRS_HOME/bin/srvctl config database -v|grep -i $database | awk '{print $2}'`
for service in `$ORACLE_HOME/bin/srvctl status service -d $database | awk '{print $2}'`
case $ORACLE_HOME in
Instance_pref=`$ORACLE_HOME/bin/srvctl config service -s $service -d $database | sed 's/\(.*: \)\(.*\)\( AVAIL:.*\)/\2/1;1q'`
Instance_avail=`$ORACLE_HOME/bin/srvctl config service -s $service -d $database | sed 's/\(.*AVAIL: \)\(.*\)/\2/g;1q'`;;
calc_pref_avail $database $service| { read Pref Avail;};;
echo $Pref "For 11g"
echo $Instance_pref "For 10g";
echo $Instance_avail "For 10g"
echo $Avail "For 10g"
pref_node=`$ORACLE_HOME/bin/srvctl status database -d $database | sed 's/\(.*Instance\)\(.*\)\( is running on node $node.*\)/\2/1;1q'`
#if $pref_node == $Instance_pref then
#$ORACLE_HOME/bin/srvctl relocate service -s $service -d $database -i $Instance_pref -t $Instance_avail

 sh -n dev-oragrid-ux01 -t pref
Host OK
targ OK
host = dev-oragrid-ux01 targ = pref[28]: syntax error at line 36 : `(' unexpected

Best regards,
# 12  
Old 12-17-2013
Hmm, which shell is /bin/sh??
# 13  
Old 12-17-2013
Yes I used below code at the top


Should I try with bash?


Best regards,
# 14  
Old 12-17-2013
That could help. It seems, /bin/sh does not understand ((.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

HP-UX: Shell Script giving " 0^J30: Syntax error"

Hi All, We are getting a very unique error while running a shell script on HP-UX box. Can somebody help in this regards? The shell script is working fine on linux/solaris box. Error: ++++++++++++++++++++++++ $/ ./ 0^J30: Syntax error $ ++++++++++++++++++++++++ TIA.... (16 Replies)
Discussion started by: vai_sh
16 Replies

2. Shell Programming and Scripting

Unable to identify error in the script

cat #!/bin/sh set -x while getopts ":n:" opt; do case "$opt" in n) host=$OPTARG shift 2 ;; -h ) host=$2 shift 2 ;; *) break ;; esac done; echo "host =... (7 Replies)
Discussion started by: Vishal_dba
7 Replies

3. Shell Programming and Scripting

script to kill a pid giving error

Hi, I simply want to kill a running process using a script that read pid from a file and tries to kill it .Getting error as shown below code.. cat $HOME/ | head -1 | while read pid do ps -p $pid > /dev/null 2>&1 if ; then kill -9 $pid else echo "no running $pid... (5 Replies)
Discussion started by: dhirajdsharma
5 Replies

4. AIX

multipath giving error

Hi, # lspath Missing hdisk0 fscsi0 Missing hdisk1 fscsi0 Missing hdisk2 fscsi0 Missing hdisk3 fscsi0 Missing hdisk4 fscsi0 Missing hdisk5 fscsi0 Missing hdisk6 fscsi0 Missing hdisk7 fscsi0 Missing hdisk8 fscsi0 Missing hdisk9 fscsi0 Missing hdisk10 fscsi0 Missing hdisk11... (2 Replies)
Discussion started by: JATA01
2 Replies

5. Shell Programming and Scripting

Script working in AIX, but giving error in SOLARIS

Hi, My script is working fine in AIX but throwing an error in SOLARIS system. Here is the error message that I am getting when calculating the elapsed time: /home/x772525/ start_mins = *60 + : syntax error . ((start_mins = $(expr substr "$j" 1 2)*60 + $(expr substr "$j" 4... (6 Replies)
Discussion started by: ajayakunuri
6 Replies

6. Shell Programming and Scripting

bc giving error: (standard_in) 2: parse error

Below part of script, is working fine sometimes and gives error sometime. I am doing float operations, checking if x > y. ##########CODE########## THRESHOLD="1.25" ratio=$( echo "scale=2; ${prev}/${current}" | bc ) if ; then split_date=`echo ${line} | cut -d, -f2` fi ... (9 Replies)
Discussion started by: manishma71
9 Replies

7. Shell Programming and Scripting

Printer status script giving error

Hi, We check the printer status at the command line by giving the following command and the system gives an output; lpstat -prn001_hp4000n When I give the same command in a UNIX script the system gives an error while running the script as "lpstat: not found". Please let me know... (8 Replies)
Discussion started by: jmathew99
8 Replies

8. Shell Programming and Scripting

A running Script giving error while scheduled in cronjob

Hi, I have script which is properly running but when i schedule it in cron it throws an error like : Your "cron" job on retrprdapp1 /usr/bin/sh /retr/cron/ 2>&1 produced the following output: /retr/cron/ syntax error at line 17: `(' unexpected line17 is # Get list of... (10 Replies)
Discussion started by: rajagasti
10 Replies

9. UNIX for Advanced & Expert Users

script giving error

Hi All, i have an small issue... echo " " eval x=$@ export x=`echo $x` echo $x ssh user@ipadrss; cd /mbbv/home/; cd /mbbv/home/orange/orange/ echo pwd bash $x above is my script which will triger from server A and will connect to server B for some... (2 Replies)
Discussion started by: Shahul
2 Replies

10. Shell Programming and Scripting

mv command is giving error in shell script

Hi, In my shell script when I am using mv command using shell variables it is giving me error of syntax. Following is the shell script: file_edifice="*.txt" fquote="'" fdquote=\" for file in $file_edifice do file_name=$fquote$file$fquote tofile_name=`date... (5 Replies)
Discussion started by: gammit
5 Replies
Login or Register to Ask a Question