Help with shell script 'CASE $'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with shell script 'CASE $'
# 1  
Old 07-17-2014
Help with shell script 'CASE $'

Hi,
I have a script that is called by /etc/init.d/S99oracle and the contents of this script are below.

Code:
$ cat ../init.d/oracle
### BEGIN INIT INFO
# Provides: oracle
# Required-Start: $ALL
# Required-Stop:
# Default-Start:  3 5
# chkconfig: 35 99 10
# Default-Stop:
# Description: Start/stop the Oracle database engine
### END INIT INFO
echo $1
case $1 in
      start)
                echo "Starting Oracle"
                 /u/bin/oracle_start
                ;;
      stop)
                echo "Stopping Oracle"
                 /u/bin/oracle_stop
                ;;
esac

Now, when I run one of the above 2 scripts (/u/bin/oracle_start
or /u/bin/oracle_stop) manually, they work fine, however when they are called on server reboot, the /u/bin/oracle_start fails. The content of /u/bin/oracle_start are below. Any advice?

Code:
 $ cat /u/bin/oracle_start
#run as root
### BEGIN INIT INFO
# Provides: oracle
# Required-Start: $ALL
# Required-Stop:
# Default-Start:  3 5
# chkconfig: 35 99 10
# Default-Stop:
# Description: Start the Oracle database engine
### END INIT INFO
set -x
DT=`date +"%m%d%H%M"`
ORACLE_LOG=/tmp/oracle_start.$DT
echo "Starting cssd." >> $ORACLE_LOG
# /u/oracle/server/oracle10g/bin/localconfig reset 2>&1 >> $ORACLE_LOG
if [ $? -ne 0 ]
then
  echo "Failure starting cssd!" >> $ORACLE_LOG
  exit 1
fi
echo "Starting ASM and database." >> $ORACLE_LOG
/bin/su oracle -c '. /u/oracle/home/.oraenv > /dev/null; $ORACLE_HOME/bin/./dbstart $ORACLE_HOME' 2>&1 >> $ORACLE_LOG
if [ $? -ne 0 ]
then
  echo "Failure starting ASM and database!!" >> $ORACLE_LOG
  echo "Continuing with Agent startup" >> $ORACLE_LOG
fi
echo "Starting Grid Control Agent." >> $ORACLE_LOG
/bin/su oracle -c '. /u/oracle/home/.oraenv > /dev/null;  $AGENT_HOME/bin/./emctl start agent' 2>&1 >> $ORACLE_LOG
if [ $? -ne 0 ]
then
  echo "Failure starting agent!" >> $ORACLE_LOG
fi


-Thanks-

Last edited by Corona688; 07-17-2014 at 12:06 PM..
# 2  
Old 07-17-2014
Please use code tags for code! [code]stuff[/code]

That init script looks fishy. if [ $? -ne 0 ] is tested without actually running anything except local commands first.

It would be useful to know what way it fails -- what ends up in the log when it fails to start.
# 3  
Old 07-17-2014
Thanks Corona for quick reply,
The log files from /u/bin/oracle_start shows as waiting for ASM to be up before it can bring the DB up. Now, we have the /etc/init.d/init.cssd on server, I want to know what run level will this script init.cssd be called during server reboot?
# 4  
Old 07-17-2014
Quote:
Originally Posted by welldone
The log files from /u/bin/oracle_start shows as waiting for ASM to be up before it can bring the DB up.
What do they actually say, though? Like I said, that init script looks fishy. I don't think it's checking ccsd at all, I think it could be quitting from errors unrelated to ccsd.
# 5  
Old 07-17-2014
The problem could be the $ORACLE_HOME environment variable.
# 6  
Old 07-17-2014
Franklin52,
No, $ORACLE_HOME is set to correct value, because the script starts DB when run manually, however it fails to auto start DB on server reboot.
# 7  
Old 07-17-2014
Quote:
Originally Posted by welldone
Franklin52,
No, $ORACLE_HOME is set to correct value
But not when the system boots up.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Restarting shell script in case of a failure

I have a shell script which sqoops data from one place to hive and it does in 2 groups list. If one group is completed it waits for the second to get completed then goto to orc load, but it it fails it kills the other groups and sends a fail email. What I was looking for is if 1 group fails, it... (1 Reply)
Discussion started by: Kunalcurious
1 Replies

2. Shell Programming and Scripting

Case statement in UNIX shell script

have written the below code to check whether the string received from user is a file name or dir using case statement, but its going into default case*). #!/bin/sh #Get a string from user and check whether its a existing filename or not rm str2 rm str3 echo "enter a file \c" read fil... (8 Replies)
Discussion started by: Mohan0509
8 Replies

3. UNIX for Advanced & Expert Users

Shell script to convert words to Title case

Hi :) I have a .txt file with thousands of words. I was wondering if i could use a simple sed or awk command to convert / replace all words in the text file to Title Case format ? Example: from: this is line one this is line two this is line three to desired output: This Is Line... (8 Replies)
Discussion started by: martinsmith
8 Replies

4. Shell Programming and Scripting

[Solved] Change Upper case to Lower case in C shell

Is there a command that can switch a character variable from UPPER case to lower case? like foreach AC ( ABC BCD PLL QIO) set ac `COMMAND($AC)` ... end Thanks a lot! (3 Replies)
Discussion started by: rockytodd
3 Replies

5. Shell Programming and Scripting

Combination of case and If else in shell script

Would it be right forme to combine case statement and if else in one shell script? Would it work? (2 Replies)
Discussion started by: Pauline mugisha
2 Replies

6. Shell Programming and Scripting

Shell script dynamically case in VAR

Hallo, I am working on a kdialog. This shall be able to load the required commands from a .conf file. First step runs good by loading the entries (selectabel entries) in a variable: MIRRORSELECT=$(kdialog --radiolist "Select your nearest mirror" $VAR1) The kdialog is accordingly correct... (2 Replies)
Discussion started by: ACTGADE
2 Replies

7. Shell Programming and Scripting

shell script case statement

In a case statement like below : case $rental in "car") echo "For $rental Rs.20 per k/m";; "van") echo "For $rental Rs.10 per k/m";; "jeep") echo "For $rental Rs.5 per k/m";; "bicycle") echo "For $rental 20 paisa per k/m";; *) echo "Sorry, I can not gat a $rental for you";;... (4 Replies)
Discussion started by: sriram003
4 Replies

8. UNIX for Advanced & Expert Users

Shell script to convert to Title case

I need a shell script which will convert the given string to Title case. E.g "hi man" to "Hi man" (5 Replies)
Discussion started by: SankarV
5 Replies

9. Shell Programming and Scripting

Shell script automation using case statement

Hi, I'm trying to write a shell script that has a menu and then dependant on the selection, will automate some samba file transfer. The problem is when I run the code without the case statement it runs fine. but when I put the case statement in the only way I can get the code to run is to... (6 Replies)
Discussion started by: ianf
6 Replies

10. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies
Login or Register to Ask a Question