Sponsored Content
Top Forums Shell Programming and Scripting Script giving error-Unable to identfiy Post 302880050 by Vishal_dba on Tuesday 17th of December 2013 09:03:48 AM
Old 12-17-2013
Below is the complete script


Code:
#!/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 OK
else
    echo Bad Host $host
fi
case "$targ" in
    pref|avail) echo targ OK;;
    *)    echo Bad argument to -t;;
esac
echo "host = $host targ = $targ"
calc_pref_avail()
{
declare -a lines
  declare -a pref
  declare -a avail

  IFS=$'\n';
  lines=`srvctl config service -d ${1} -s ${2}|egrep '^(Preferred|Available) instances:'`;
  for ((i=0;i<${#lines[@]};i++))
  do
    line=${lines[$i]};
    IFS=$'\n';
    if [ "${line:0:21}" = 'Preferred instances: ' ]; then
      pref=($(echo "${line:21}"|sed 's/,/\n/g'));
    else
      avail=($(echo "${line:21}"|sed 's/,/\n/g'));
    fi
  done
  # array with preferred instances
  for ((m=0;m<${#pref[@]};m++))
  do
    echo " ${pref[$m]} "
  done
  # array with available instances
  for ((m=0;m<${#avail[@]};m++))
  do
     echo " ${avail[$m]} "
  done
}
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)}'`
  do
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}'`
do
c="/product/10"
case $ORACLE_HOME in
  */product/10*)
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
 done
done


Best regards,
Vishal
 

10 More Discussions You Might Find Interesting

1. 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

2. 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 samplescript.sh $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

3. 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/ftp.sh 2>&1 produced the following output: /retr/cron/ftp.sh: syntax error at line 17: `(' unexpected line17 is # Get list of... (10 Replies)
Discussion started by: rajagasti
10 Replies

4. 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

5. 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

6. 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/FindETA.sh: 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

7. 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

8. 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/BackupScript.ksh.run | 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

9. Shell Programming and Scripting

Unable to identify error in the script

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 =... (7 Replies)
Discussion started by: Vishal_dba
7 Replies

10. 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: ++++++++++++++++++++++++ $/test.sh ./test.sh: 0^J30: Syntax error $ ++++++++++++++++++++++++ TIA.... (16 Replies)
Discussion started by: vai_sh
16 Replies
Test::Script(3) 					User Contributed Perl Documentation					   Test::Script(3)

NAME
Test::Script - Basic cross-platform tests for scripts DESCRIPTION
The intent of this module is to provide a series of basic tests for 80% of the testing you will need to do for scripts in the script (or bin as is also commonly used) paths of your Perl distribution. Further, it aims to provide this functionality with perfect platform-compatibility, and in a way that is as unobtrusive as possible. That is, if the program works on a platform, then Test::Script should always work on that platform as well. Anything less than 100% is considered unacceptable. In doing so, it is hoped that Test::Script can become a module that you can safely make a dependency of all your modules, without risking that your module won't on some platform because of the dependency. Where a clash exists between wanting more functionality and maintaining platform safety, this module will err on the side of platform safety. FUNCTIONS
script_compiles script_compiles( 'script/foo.pl', 'Main script compiles' ); The "script_compiles" test calls the script with "perl -c script.pl", and checks that it returns without error. The path it should be passed is a relative unix-format script name. This will be localised when running "perl -c" and if the test fails the local name used will be shown in the diagnostic output. Note also that the test will be run with the same perl interpreter that is running the test script (and not with the default system perl). This will also be shown in the diagnostic output on failure. script_runs script_runs( 'script/foo.pl', 'Main script runs' ); The "script_runs" test executes the script with "perl script.pl" and checks that it returns success. The path it should be passed is a relative unix-format script name. This will be localised when running "perl -c" and if the test fails the local name used will be shown in the diagnostic output. The test will be run with the same perl interpreter that is running the test script (and not with the default system perl). This will also be shown in the diagnostic output on failure. SUPPORT
All bugs should be filed via the bug tracker at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Script> For other issues, or commercial enhancement and support, contact the author. AUTHOR
Adam Kennedy <adamk@cpan.org> SEE ALSO
prove, <http://ali.as/> COPYRIGHT
Copyright 2006 - 2009 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.18.2 2009-11-23 Test::Script(3)
All times are GMT -4. The time now is 11:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy