Unable to identify error in the script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to identify error in the script
# 1  
Old 12-03-2013
Unable to identify error in the script

Code:
cat test3.sh
#!/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 = $host "
export CRS_HOME=/devoragridcn_01/Grid_11203
#for service in `$CRS_HOME/bin/crsctl status res -n $host| grep -E "ora\.$DATABASE\.(.+)\.svc" | awk -F"." '{print $(NF-2)}'`

#{
for database in `$CRS_HOME/bin/crsctl status res -n $host| grep -E "ora.*\.db" | awk -F"." '{print $(NF-1)}'`
  do
  {
#DBCONFIG=`$CRS_HOME/bin/srvctl config database -d $database | grep ORACLE_HOME
#declare -r "$DBCONFIG"
#echo "ORACLE_HOME=$ORACLE_HOME" ;
echo " Checking services for database $database"
#ORA_HOME=`$CRS_HOME/bin/srvctl config database -v|grep -i $database | awk '{print $2}'`
export ORACLE_HOME=`$CRS_HOME/bin/srvctl config database -v|grep -i $database | awk '{print $2}'`
#export ORACLE_HOME=$ORA_HOME
#echo $ORACLE_HOME
#export PATH=/usr/java131/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb::/usr/bin/X11:/sbin:/bin:.:/usr/local/bin:.:CRS_HOME/bin:$ORACLE_HOME/bin
#$ORACLE_HOME/bin/srvctl status service -d $database|awk '{print $2}'
$ORACLE_HOME/bin/srvctl status service -d $database | awk '{print $2}'
# i   for service in `crsctl status res -n $host| grep -E "ora\.$database\.(.+)\.svc" | awk -F"." -vDB=$database 'match ($0, "ora\."DB"\..*\.svc) {sub ("^.*\."DB"\.",""); sub (/\.svc$/,"");print}'`
 #i#         do
  #          {
   #          echo "Checking service $service on Database $database"
    #        }
     #     done
  }
  done
set +x

Code:
/devoragridcn_01/app/oracle/work/vishal> ./test3.sh -n dev-oragrid-ux01
+ getopts :n: opt
+ case "$opt" in
+ host=dev-oragrid-ux01
+ shift 2
+ getopts :n: opt
+ echo 'host = dev-oragrid-ux01 '
host = dev-oragrid-ux01
+ export CRS_HOME=/devoragridcn_01/Grid_11203
+ CRS_HOME=/devoragridcn_01/Grid_11203
++ /devoragridcn_01/Grid_11203/bin/crsctl status res -n dev-oragrid-ux01
++ grep -E 'ora.*\.db'
++ awk -F. '{print $(NF-1)}'
+ for database in '`$CRS_HOME/bin/crsctl status res -n $host| grep -E "ora.*\.db" | awk -F"." '\''{print $(NF-1)}'\''`'
+ echo ' Checking services for database cmdbut'
 Checking services for database cmdbut
++ /devoragridcn_01/Grid_11203/bin/srvctl config database -v
++ grep -i cmdbut
++ awk '{print $2}'
+ ORACLE_HOME='[
[
[
[
/devoragridcn_01/app/oracle/product/11203'
+ echo '[' '[' '[' '[' /devoragridcn_01/app/oracle/product/11203
[ [ [ [ /devoragridcn_01/app/oracle/product/11203
+ '[' '[' '[' '[' /devoragridcn_01/app/oracle/product/11203/bin/srvctl status service -d cmdbut
./test3.sh: line 37: [: missing `]'
+ awk '{print $2}'
+ for database in '`$CRS_HOME/bin/crsctl status res -n $host| grep -E "ora.*\.db" | awk -F"." '\''{print $(NF-1)}'\''`'
+ echo ' Checking services for database lms_dry'
 Checking services for database lms_dry
++ /devoragridcn_01/Grid_11203/bin/srvctl config database -v
++ grep -i lms_dry
++ awk '{print $2}'
+ ORACLE_HOME='[
[
[
[
/devoragridcn_01/app/oracle/product/11203'
+ echo '[' '[' '[' '[' /devoragridcn_01/app/oracle/product/11203
[ [ [ [ /devoragridcn_01/app/oracle/product/11203
+ '[' '[' '[' '[' /devoragridcn_01/app/oracle/product/11203/bin/srvctl status service -d lms_dry
./test3.sh: line 37: [: missing `]'
+ awk '{print $2}'


Best regards,
Vishal

Last edited by Corona688; 12-03-2013 at 04:20 PM..
# 2  
Old 12-03-2013
Hi,
what return this command ?
Code:
/devoragridcn_01/Grid_11203/bin/srvctl config database -v|grep -i cmdbut | awk '{print $2}'

Regards.
# 3  
Old 12-03-2013
Hi ,

Code:
/devoragridcn_01/app/oracle> /devoragridcn_01/Grid_11203/bin/srvctl config database -v|grep -i cmdbut | awk '{print $2}'
/devoragridcn_01/app/oracle/product/11203



Best regards,
Vishal
# 4  
Old 12-03-2013
Strange...
And this command:
Code:
/devoragridcn_01/Grid_11203/bin/srvctl config database -v|grep -i cmdbut | awk '{print $2}' | od -c

Regards.
# 5  
Old 12-03-2013
Code:
/devoragridcn_01/app/oracle> /devoragridcn_01/Grid_11203/bin/srvctl config database -v|grep -i cmdbut | awk '{print $2}' | od -c
0000000    /   d   e   v   o   r   a   g   r   i   d   c   n   _   0   1
0000020    /   a   p   p   /   o   r   a   c   l   e   /   p   r   o   d
0000040    u   c   t   /   1   1   2   0   3  \n
0000052


Best regards,
Vishal
# 6  
Old 12-03-2013
What's your OS?
what's the output of echo $0 executed from a shell?
Also, you don't have to have ' do {...} done' - 'do .... done' will do - try getting rid of the embedded {}

Last edited by vgersh99; 12-03-2013 at 07:29 PM..
# 7  
Old 12-03-2013
Could you post good script ?
I don't found the line:
Code:
+ echo '[' '[' '[' '[' /devoragridcn_01/app/oracle/product/11203

This echo is comment in your post Smilie
Regards.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to identify the special characters beyond the range of "[\x80-\xFF]"

I want to filter out the special character whose ascii value doesn't fall within the range "" . Example:� or Ć. So in that case is there any defined range which will filter out this characters. I can filter those which falls withing "" . Need to filter those special chracter which doesn't... (14 Replies)
Discussion started by: Abhijit Sen
14 Replies

2. Shell Programming and Scripting

Script giving error-Unable to identfiy

#!/bin/sh #!/bin/prel #set -x while getopts ":n:t:" opt; do case "$opt" in n) host=$OPTARG ;; t) targ=$OPTARG ;; *) break ;; esac done if ping -c 2 $host >/dev/null 2>&1 then echo Host... (17 Replies)
Discussion started by: Vishal_dba
17 Replies

3. Shell Programming and Scripting

Identify variables used in the shell script

Hi, Is there any simple way to get/identify the variables that are used in a file and print those variable names. If I have something like this in a file, /$var/temp_dir/${var2}${var3}.log I want to display the variables 'var', 'var2' and 'var3' from that file. I tried something like... (6 Replies)
Discussion started by: pvamsikr
6 Replies

4. Shell Programming and Scripting

How to identify whether the script is in Unix format or not ?

Hi All, I have the below scenario in my environment Developers used to copy file from windows to Linux box. Some time on the copied file developers miss to run the dos2unix utility. Because of this script gets failed during the execution. Most of the failures are due to the dos2unix format... (7 Replies)
Discussion started by: kalpeer
7 Replies

5. Shell Programming and Scripting

Script to Identify if folder has a file in it

Hi everyone I am new to the forums. I haven't done much linux myself but I have been asked if I can do the following. Write a linux script that needs to scan a certain folder every x amount of minutes and if there is a file in the folder then it needs to call a different script. Is this... (2 Replies)
Discussion started by: Bosbaba
2 Replies

6. Shell Programming and Scripting

Using an awk script to identify dupes in two files

Hello, I have two files. File1 or the master file contains two columns separated by a delimiter: a=b b=d e=f g=h File 2 which is the file to be processed has only a single column a h c b What I need is an awk script to identify unique names from file 2 which are not found in the... (6 Replies)
Discussion started by: gimley
6 Replies

7. Shell Programming and Scripting

Identify script please!

Have a script that I'm trying to adapt for something else, but I do not understand the following lines. Can anyone help? I know what expr does, `expr 8 + 2`, but: FILENAME=`expr //$FILE : '.*/\(.*\)'` UNPACKDIR=`echo $FILE | sed -e s/$FILENAME//g` Thanks (6 Replies)
Discussion started by: bound4h
6 Replies

8. AIX

Script to identify high CPU usage processes

Hi Guys, I need to write a script capable of identifying when a high cpu utilitzation process. It sounds simple but we are on a AIX 5.3 environment with Virtual CPU's (VP's) and logical CPU's. Please any ideas or tips would be highly appreciated. Thanks. Harby. (6 Replies)
Discussion started by: arizah
6 Replies

9. Shell Programming and Scripting

test script to identify SHELL

I am new to BASH and writing a small script to identify the SHELL . #!/bin/bash BASH='/bin/bash' KSH='/bin/ksh' if then echo "it's Bash" else echo "it's not Bash" fi $ bash -x a.sh + BASH=/bin/bash + KSH=/bin/ksh + '' a.sh: line 4: where am I missing . PLease advice . (10 Replies)
Discussion started by: talashil
10 Replies

10. Shell Programming and Scripting

How to identify the calling script?

Hi, I have two scripts ( /tmp/k1.sh and /tmp/k2.sh ). k1.sh calls the k2.sh . For security reasons, I must be sure that the k2.sh is being called by the k1.sh . Is it possible for the k2.sh identify that it's been called by the k1.sh? I mean, identify the complete path of the k1.sh (... (6 Replies)
Discussion started by: crematoriumm
6 Replies
Login or Register to Ask a Question