Start more than one database - trouble with for loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Start more than one database - trouble with for loop
# 1  
Old 05-26-2006
Start more than one database - trouble with for loop

I have seen this done before - and maybe there is a better way too.

I want to be abe to use a for loop (or other better method) to loop through the database instance names that are part of the script - not an external file where a read might be ok.

Here is what I have and I know won't work - but to give you'all an idea of what I am trying to do.

#!/bin/ksh

...
...

OPER="list of database instances here"

for i in $OPER
do

case "$1" in
'start')
;
;

'stop')
;
;
esac
done
# 2  
Old 05-26-2006
For starters it would be
Code:
case "$i"

not $1

It's a mistake everyone makes.
# 3  
Old 05-26-2006
This is called at system boot time (which gets the start/stop argument) :

What I want to do is case the $1 start/stop as indidcated but for each database do either "start" or "stop".
# 4  
Old 05-26-2006
Ok. FWIW - I don't understand why an instance would be running at boot time and need to be stopped...

I also do not see why this fails a priori. Do you get error messages?
Are you sure that all the needed environment variables are set so you can start each instance - assuming Oracle:PATH, ORACLE_HOME for example. You code should work from a logic point of view, therefore it has to be failing for another set of reasons:

bad environment (most likely):
including PATH or LD_LIBRARY_PATH or SHLIB_PATH to runtimes
permissions (not likely)
other errors in coding the calls to start/stop the instance.
# 5  
Old 05-27-2006
Quote:
Originally Posted by jim mcnamara
Ok. FWIW - I don't understand why an instance would be running at boot time and need to be stopped...
It looks like he's setting up an init.d script, where you can call it with the "start" arg at startup, "stop" at shutdown, "status" anywhere inbetween, etc...
# 6  
Old 05-30-2006
Correct

The script will be called with "start"/"stop" as arguments. Typically at start start up or shutdown - although it could be run anytime with the correct arguments.


db_script start
db_script stop


When it does I want to loop through all the databases - not just one. And I prefer that db start list be in the script (not read in from a file - although I could be convienced otherwise).

If there is a better way great.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Considerable trouble with for loop in combination with awk

I have the text file where each line has the format: chr10 101418889 101418904 0.816327 Right now the interval between column 2 and 3 is 15. I only want the two consecutive positions starting at position 1, write it to a file, then move up one position write to file etc. So that: ... (1 Reply)
Discussion started by: jfern
1 Replies

2. UNIX for Dummies Questions & Answers

Trouble understand and using for loop

Good evening all I have what might be a simple problem to solve but I do not know how to solve it myself. I am writing a bash script and my code looks something like this: mp3=`ls | grep \.mp3` for f in $mp3 do echo $f done Basically what I want to do is look through the current... (4 Replies)
Discussion started by: mistsong1
4 Replies

3. UNIX for Dummies Questions & Answers

Trouble displaying parameters passed into a for loop

#!/bin/bash function check_num_args() { if ; then echo "Please provide a file name" else treat_as_file $* fi } function treat_as_file() { numFiles=$# for((i=1;i<=$numFiles;i++));do echo $i ... (3 Replies)
Discussion started by: kikilahooch
3 Replies

4. Programming

trouble with loop counting

HI there, I am trying to count manually what this code does but I am stuck and I don't learly see the result. The code works and it compiles and runs but I just don't follow the value of var. #include<stdio.h> #include<stdlib.h> #include<sys/types.h> #include<unistd.h> #include<wait.h>... (2 Replies)
Discussion started by: bluetxxth
2 Replies

5. Shell Programming and Scripting

Trouble with a file path as awk output in for loop

When I run the following command in the shell it works fine. It prints a city name and then a path for a file. ~$ for i in `awk -F':' '{print $0}' /home/knoppix/Desktop/data/subs | grep -m 1 $ city | sed "s/:/ /"` >do >echo $i >done Now, when I place it in this shell script (sh) it prints... (6 Replies)
Discussion started by: afroCluster
6 Replies

6. Shell Programming and Scripting

for loop syntax trouble

i don't get what's wrong here. i'm writing a shell script that takes 1 argument (a number) from the command-line, but it's throwing an error: Syntax error: Bad for loop variable doesn't make much sense for (( i = 1; i = ${1}; i++ )) # error points to this line everytime do echo... (9 Replies)
Discussion started by: visitorQ
9 Replies

7. Solaris

Database can't start automatically on solaris

Hi, I have installed oracle 9i on solaris 10 sucessfully. I have configured listener & tnsname.ora file sucessfuly. Even i can start database manully by starting listener first and from sqlplus promt data base sucessfully. Now i want to start the database automatically after system reboots. I... (2 Replies)
Discussion started by: Sachin Vaidya
2 Replies

8. Shell Programming and Scripting

Loop Trouble

Can anyone tell me what's wrong with my code here? I'm experiencing weird behavior... I am using 'j' to go down a list filenames saved in a .txt file and prompting the user whether or not she would like to delete each one. This works all well and fine the first run through, but then instead of... (2 Replies)
Discussion started by: RSymphony
2 Replies

9. Solaris

How to start Oracle database automatically

How to start Oracle database automatically when after SunSolaris is being re-booted? TIA, Greg (3 Replies)
Discussion started by: greg0320
3 Replies
Login or Register to Ask a Question