1834150 Members
2376 Online
110064 Solutions
New Discussion

script help

 
SOLVED
Go to solution
Sanjiv Sharma_1
Honored Contributor

script help

Hi,

I want to have a script. The funtion of this script is to check a list of database names from a text file and then execute another 3 numbers scripts(available with me) for each of the names.

Text file:
DB1
DB2
DB3
DB4
etc...

My new script should read DB1 first and then execute about 3 more scripts.
Then it reads DB2 and execute the same three scripts and so on till the last DB.

Thanks,
Everything is possible
10 REPLIES 10
KapilRaj
Honored Contributor
Solution

Re: script help

for DBASE in `cat textfile`
do
case $DBASE in
DB1) scr1,scr2,scr3 ;;
DB2) scr4,scr5,scr6 ;;
...
..
esac
done

Is this what u need ?

Kaps
Nothing is impossible
Vijaya Kumar_3
Respected Contributor

Re: script help



create a text file named testfile


then this piece of code will do:

###BEGIN SCRIPT
for i in `cat testfile`
do
/myscript1 $i #Execute Script1
/myscript2 $i #Execute Script2
/myscript3 $i #Execute Script3
done
###END SCRIPT


Here i am passing the values as parameters to the script.

Hope this helps
vj
Known is a drop, unknown is ocean - visit me at http://vijay.theunixplace.com
Sanjiv Sharma_1
Honored Contributor

Re: script help

It is not very clear to me.
Lets be more specific:

Text filename is testfile.
Contents of the file is
DB1
DB2
DB3
etc...

My three scripts are :
/home/oracle/scripts/a.sh
/home/oracle/scripts/b.sh
/home/oracle/scripts/c.sh

Thanks,



Everything is possible
Vijaya Kumar_3
Respected Contributor

Re: script help



$ cat testfile
DB1
DB2
DB3
...
$

Then the script is mine.sh

$ cat mine.sh
###BEGIN SCRIPT
for i in `cat testfile`
do
/home/oracle/scripts/a.sh
/home/oracle/scripts/b.sh
/home/oracle/scripts/c.sh
done
###END SCRIPT
$
$ ksh mine.sh


it will do what you want

Hope this helps
Vijay
Known is a drop, unknown is ocean - visit me at http://vijay.theunixplace.com
Vijaya Kumar_3
Respected Contributor

Re: script help

I really dont understand why are you running these without a need for DB1,DB2 values.

Generally, you may need this value inside the script.

Can u please tell what are you going to do with Db1,Db2 etc , inside the script.

Vijay
Known is a drop, unknown is ocean - visit me at http://vijay.theunixplace.com
V.Tamilvanan
Honored Contributor

Re: script help

Hi sanjiv,
This below script should help you.

for DBASE in `cat testfile`
do
case $DBASE in
DB1) /home/oracle/scripts/a.sh ;;
DB2) /home/oracle/scripts/b.sh ;;
DB3) /home/oracle/scripts/c.sh ;;
esac
done
Sanjiv Sharma_1
Honored Contributor

Re: script help

Hi Vijaya,

Yes. Maybe I wat not clear.
I want the tree script to run on DB1 and then on DB2 and so on..

What should we need to change on your given script to incorporate this?
Everything is possible
V.Tamilvanan
Honored Contributor

Re: script help

Hi sanjiv,
The earlier one was for a single script . but the below one for multiple scripts.

for DBASE in `cat testfile`
do
case $DBASE in
DB1) /home/oracle/scripts/a.sh; /home/oracle/scripts/b.sh; /home/oracle/scripts/c.sh ;;
DB2) .................;;
DB3) .................;;

esac
done




HTH.
KapilRaj
Honored Contributor

Re: script help

Are you done sanjiv ?. Actually i did not really uinderstand ur requirement !

Kaps
Nothing is impossible
Sanjiv Sharma_1
Honored Contributor

Re: script help

I believe Tamil's second response should work.

I will get back after testing it.

Thank you all.
Everything is possible