Link to home
Start Free TrialLog in
Avatar of oracheck
oracheck

asked on

error while running the scirpt

Hi

I have created a script to run the following task but it throwing me sysntax error.I am unable to catch it as everything looks ok for me.Can some please help me.Also please do let me know if need do any changes  for the below scirpt.

Task:
2.      Validate db file placement is correct (ie. each file should be on mount point shown and no other files should be in those dirs with the exception of oradata07)

/local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf
/local/$APP_NAME/oradata02/$ORACLE_SID/sysaux_01.dbf
/local/$APP_NAME/oradata06/$ORACLE_SID/undo_01.dbf
/local/$APP_NAME/oradata03/$ORACLE_SID/temp_01.dbf
/local/$APP_NAME/oradata07/$ORACLE_SID/tools_01.dbf
/local/$APP_NAME/oradata07/$ORACLE_SID/users_01.dbf

Script:
+1
    +2
    +3  echo "Please enter the app name that was used to name the mount points: "
    +4  read APP_NAME
    +5  echo "Please enter the Oracle SID: "
    +6  read DB_NAME
    +7  echo
    +8  echo
    +9
   +10
   +11  ###checking to see if mount point exists######
   +12  echo "1."
   +13  for i in /local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf/*
   +14  do
   +15   mount | awk '{print $2}' | grep $i > /dev/null
   +16   if [ $?=0 ]
   +17     then
   +18       echo " $i is mounted"
   +19     else
   +20        echo " $i is not mounted"
   +21     fi
   +22
   +23
   +24  echo "2."
   +25  for i in /local/$APP_NAME/oradata02/$ORACLE_SID/sysaux_01.dbf/*
   +26  do
   +27   mount | awk '{print $2}' | grep $i > /dev/null
   +28   if [ $?=0 ]
   +29    then
   +30       echo " $i is mounted"
   +31     else
   +32        echo " $i is not mounted"
   +33     fi
   +34
   +35
   +36  echo "3."
   +37  for i in /local/$APP_NAME/oradata06/$ORACLE_SID/undo_01.dbf/*
   +38  do
   +39   mount | awk '{print $2}' | grep $i > /dev/null
   +40   if [ $?=0 ]
   +41    then
   +42       echo " $i is mounted"
   +43     else
   +44        echo " $i is not mounted"
   +45     fi
   +46
   +47  echo "4."
   +48  for i in /local/$APP_NAME/oradata03/$ORACLE_SID/temp_01.dbf/*
   +49  do
   +50   mount | awk '{print $2}' | grep $i > /dev/null
   +51   if [ $?=0 ]
   +52    then
   +53       echo " $i is mounted"
   +54     else
   +55        echo " $i is not mounted"
   +56     fi
   +57
   +58
   +59  echo "5."
   +60  for i in /local/$APP_NAME/oradata07/$ORACLE_SID/tools_01.dbf/*
   +61  do
   +62   mount | awk '{print $2}' | grep $i > /dev/null
   +63   if [ $?=0 ]
   +64    then
   +65       echo " $i is mounted"
   +66     else
   +67        echo " $i is not mounted"
   +68     fi
   +69
   +70  echo "6."
   +71  for i in /local/$APP_NAME/oradata07/$ORACLE_SID/users_01.dbf/*
   +72  do
   +73   mount | awk '{print $2}' | grep $i > /dev/null
   +74   if [ $?=0 ]
   +75    then
   +76       echo " $i is mounted"
   +77     else
   +78        echo " $i is not mounted"
   +79     fi
   +80  done



error:
1.
./ora.ksh[13]: 0403-057 Syntax error at line 60 : `for' is not matched.
Avatar of ThomasHorsten
ThomasHorsten
Flag of United Kingdom of Great Britain and Northern Ireland image

You need a "done" for each "do" in your script. These terminate the "for" execution blocks.

Line 22, 34, 46, 57, 59 should contain "done".
Avatar of Steve24by7
Steve24by7

Should have a done for each do, perhaps?
Avatar of woolmilkporc
Hi,
each "for ... do" must be terminated with a "done", which you are missing 5 times.
Place "done" according to your logic.
I haven't checked in detail, but I think you're not trying to nest the "for" loops, so place a "done" statement just one line above the next "for" (following the "echo")
wmp
... or maybe preceeding the echo.
Avatar of oracheck

ASKER

Hi Experts,

Thanks for ur responses.I just ran the script and it shows that

/local/ccw01/oradata02/DUMMY/system_01.dbf/* is mounted
2.
 /local/ccw01/oradata02/DUMMY/sysaux_01.dbf/* is mounted
3.
 /local/ccw01/oradata06/DUMMY/undo_01.dbf/* is mounted
4.
 /local/ccw01/oradata03/DUMMY/temp_01.dbf/* is mounted
5.
 /local/ccw01/oradata07/DUMMY/tools_01.dbf/* is mounted
6.
 /local/ccw01/oradata07/DUMMY/users_01.dbf/* is mounted

Actual purpose of my script was to validate db file placement is correct(ie each file should be mount point shown and no other files should be in those dirs with the exception of oradata07.Can some one please give me hint how to create this kind of script.Thanks in advance

/local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf
/local/$APP_NAME/oradata02/$ORACLE_SID/sysaux_01.dbf
/local/$APP_NAME/oradata06/$ORACLE_SID/undo_01.dbf
/local/$APP_NAME/oradata03/$ORACLE_SID/temp_01.dbf
/local/$APP_NAME/oradata07/$ORACLE_SID/tools_01.dbf
/local/$APP_NAME/oradata07/$ORACLE_SID/users_01.dbf
Hi,

I have created a script fot the above task and it is throwing errors.Can some one please guide me through.

Script:
echo "Please enter the app name that was used to name the mount points: "
read APP_NAME
echo "Please enter the Oracle SID: "
read ORACLE_SID
echo
echo



system_01.dbf=`grep "system_0.1.dbf" $/local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf|cut -f2 -d"="`

if ( [ ${system_01.dbf:-1}="/local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf" ] )
 then
    echo "system_01.dbf directory exits"
    esle
    echo "stsem_01.dbf directory doesn't exists"
fi
exit


errors:

grep: 0652-033 Cannot open $/local/ccw01/oradata02/MSET01X/system_01.dbf.
./system.sh[12]: system_01.dbf=:  not found.
./system.sh[14]: ${system_01.dbf:-1}="/local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf": 0403-011 The specified substitution is not valid for this command.
$/local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf

Remove the $ sign at the beginning

if ( [ ${system_01.dbf:-1} = "/local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf"  ] )

Put spaces around the equal sign in comparisons! (as opposed to variable assignments!)

esle

should be "else"
Hi Woolmilkproc,
I modified the script but i am still getting these errors.Can you please help
script:
echo "Please enter the app name that was used to name the mount points: "
read APP_NAME
echo "Please enter the Oracle SID: "
read ORACLE_SID
echo
echo

echo "validating the db file placement......"

system_01.dbf=`$(grep "system_01.dbf" /local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf|cut -f2 -d"=")`

if ( [ ${system_01.dbf} = "/local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf" ] )
 then
    echo "system_01.dbf directory exits"
    else
    echo "system_01.dbf directory doesn't exists"
fi
exit

error:
./sys3.sh[12]: system_01.dbf=:  not found.
./sys3.sh[14]: ${system_01.dbf}: 0403-011 The specified substitution is not valid for this command.
system_01.dbf directory doesn't exists

1) Use either backticks ( `  ... ` ) or $( ... ) , not both together!

2) If you're trying to achieve what the subsequent message suggests  - just verifying the existence of a directory  - there is a built-in test option "-d" just for that purpose -

if [ -d "/local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf" ]
  then
    echo "system_01.dbf directory exits"
     else
       echo  "system_01.dbf directory doesn't exist"
fi

There are more such options. Check e.g. for regular files with "-f", for executables with "-x" etc.

Issue "man test" to learn more.

wmp
Well,

re-reading your statement I now saw that system_01.dbf is obviously not a directory, but a file.

To take this into account, and to incorporate your check for just one file in that directory we could do this -

if [ -f /local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf  ]
  then
   if [ $(ls -1 /local/$APP_NAME/oradata02/$ORACLE_SID | wc -l) -gt 1 ]
    then  
      echo "File /local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf exists, but is not the only file in dir"
        else echo "File /local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf  exists as the only file in dir"
    fi
      else
       echo  "File /local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf doesn't exist"
fi


If you wish we can make it one level more fine-grained (check directory and file separately):

if [ -d /local/$APP_NAME/oradata02/$ORACLE_SID ]
  then
    if [ -f /local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf   ]
       then
        if [ $(ls -1 /local/$APP_NAME/oradata02/$ORACLE_SID  | wc -l) -gt 1 ]
          then  
           echo "File /local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf  exists, but not as the only file in dir"
            else  echo "File /local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf   exists as the only file in dir"
        fi
       else
       echo  "File /local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf  doesn't exist, but directory does"
    fi
    else
       echo "Directory /local/$APP_NAME/oradata02/$ORACLE_SID doesn't exist"
 fi

Check your other directories analogously.
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
woolmilkporc,

Thanks for ur suggestions.Here i have one more question..sorry to bother you too much.Well i got a desired out come (whether the particualar db files are prsent in those directories or not) with the below script  but now i need to create a  script which should say  no other file should be in those directories except those db files..How to create that script.please let me know
Task:
2.      Validate db file placement is correct (ie. each file should be on mount point shown and no other files should be in those dirs with the exception of oradata07)

/local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf
/local/$APP_NAME/oradata02/$ORACLE_SID/sysaux_01.dbf
/local/$APP_NAME/oradata06/$ORACLE_SID/undo_01.dbf
/local/$APP_NAME/oradata03/$ORACLE_SID/temp_01.dbf
/local/$APP_NAME/oradata07/$ORACLE_SID/tools_01.dbf
/local/$APP_NAME/oradata07/$ORACLE_SID/users_01.dbf


Scirpt:
echo "Please enter the app name that was used to name the mount points: "
read APP_NAME
echo "Please enter the Oracle SID: "
read ORACLE_SID
echo
echo

echo "validating the db file placement......"


if ( [ -f "/local/$APP_NAME/oradata02/$ORACLE_SID/system_01.dbf" ] )
 then
    echo "$system_01.dbf is in the correct location"
    else
    echo "$system_01.dbf might not be in the correct location"

fi


if ( [ -f "/local/$APP_NAME/oradata02/$ORACLE_SID/sysaux_01.dbf" ] )
 then
    echo "$sysaux_01.dbf is in the correct location"
    else
    echo "$sysaux_01.dbf might not be in the correct location"

fi


if ( [ -f "/local/$APP_NAME/oradata06/$ORACLE_SID/undo_01.dbf" ] )
 then
    echo "undo_01.dbf is in the correct location"
    else
    echo "undo_01.dbf might not be in the correct location"

fi


if ( [ -f "/local/$APP_NAME/oradata03/$ORACLE_SID/temp_01.dbf" ] )
  then
    echo "temp_01.dbf is in the correct location"
    else
    echo "temp_01.dbf might not be in the correct location"

fi


if ( [ -f "/local/$APP_NAME/oradata07/$ORACLE_SID/tools_01.dbf" ] )
 then
    echo "tools_01.dbf is in the correct location"
    else
    echo "tools_01.dbf might not be in the correct location"

fi


if ( [ -f "/local/$APP_NAME/oradata07/$ORACLE_SID/users_01.dbf" ] )
 then
    echo "users_01.dbf is in the correct location"
    else
    echo "users_01.dbf might not be in the correct location"

fi
exit
Did you take note of my last version?
I applogise...i did not take note of it.Well,I did run the above script but it throws the below errors

File /local/ccw01/oradata02/MSET01X/system_01.dbf  exists, but number of files in /local/ccw01/oradata02/MSET01X is not correct (2)
File /local/ccw01/oradata02/MSET01X/sysaux_01.dbf  exists, but number of files in /local/ccw01/oradata02/MSET01X is not correct (2)
File /local/ccw01/oradata06/MSET01X/undo_01.dbf  exists, but number of files in /local/ccw01/oradata06/MSET01X is not correct (1)
File /local/ccw01/oradata03/MSET01X/temp_01.dbf exists in /local/ccw01/oradata03/MSET01X, number of files is correct (1)
File /local/ccw01/oradata07/MSET01X/tools_01.dbf  exists, but number of files in /local/ccw01/oradata07/MSET01X is not correct (2)
File /local/ccw01/oradata07/MSET01X/users_01.dbf  exists, but number of files in /local/ccw01/oradata07/MSET01X is not correct (2)
So I assume there are more files in the respective subdirectories than the ones you posted?

If so, we would need quite a different logic.
yes,your right .I just checked there are some other files ...

 #cd /local/ccw01/oradata02/MSET01X
#ls
control01.ctl  sysaux_01.dbf  system_01.dbf

#cd /local/ccw01/oradata06/MSET01X
ls
control02.ctl  undo_01.dbf
Before we continue researching,
please let me first correct the mistakes I made.

The last seven lines of my script must read

...
 else
            echo  "File$OBJECT doesn't exist, but directory does"
         fi
          else
              echo "Directory $OBJDIR  doesn't exist"
      fi
  done

One thing which could lead to the messages you encountered -
did you actually use

if [ $(ls -1 $OBJDIR   | wc -l) -ne $num ]
               then  
...

It's the number one ("1"), not the letter "l" !



SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes i did use number one(1) not the letter "i".I tried to run the script with the above changes in the last 7 lines.I still got this error.

File /local/ccw01/oradata02/MSET01X/system_01.dbf  exists, but number of files in /local/ccw01/oradata02/MSET01X is not correct (2)
File /local/ccw01/oradata02/MSET01X/sysaux_01.dbf  exists, but number of files in /local/ccw01/oradata02/MSET01X is not correct (2)
File /local/ccw01/oradata06/MSET01X/undo_01.dbf  exists, but number of files in /local/ccw01/oradata06/MSET01X is not correct (1)
File /local/ccw01/oradata03/MSET01X/temp_01.dbf exists in /local/ccw01/oradata03/MSET01X, number of files is correct (1)
File /local/ccw01/oradata07/MSET01X/tools_01.dbf  exists, but number of files in /local/ccw01/oradata07/MSET01X is not correct (2)
File /local/ccw01/oradata07/MSET01X/users_01.dbf  exists, but number of files in /local/ccw01/oradata07/MSET01X is not correct (2)
woolmilkporc
Everything is working fine now.I appreciate for your time and patience.Thank you very much.
I've requested that this question be deleted for the following reason:

                           
No comment has been added to this question in more than 21 days, so it is now classified as abandoned and is now flagged for deletion.


If there is a valid solution, please OBJECT and indicate the comments that are, or would otherwise lead to, a solution.


Use the specific format http:#axxxxxxxx for comment ID(s).


Also, please don't object simply because the author did not respond to your comment. While we understand this is frustrating, unfortunately we cannot force the author to return to the question. Unless you feel you have presented a valid, verifiable solution we'll simply delete the question.


Experts-Exchange Auto Deleter
The author said "Everything is working fine now".

Looking at the many comments I'm sure that a combination of

http:#a32834027 
and
http:#a32835110

led them to the desired result, so i'd suggest accepting both and splitting points.

wmp