I am attempting to create a script that would allow me to list all the instances associated with a DB2 and then prompt the user to choose which one to issue the db2profile command against. I use the db2 command db2ilist to get a list of the instances for a particular server, but the number of instances could vary from server to server and I can't figure out how use the results from the db2ilist to create a case.
The output from db2ilist looks like this for example
[sslaton@Z11LD003 ~]$ db2ilist
dtrnd1
scgnd1
scgnd2
scgnd3
dtrnl1
scgnl1
scgnl2
scgnl3
I created a dumbed down version where I hard coded those instances to create a pick list to demonstrate what I'd like to do.
#!/bin/sh
echo "DB2 INSTANCE PROFILER UTILITY"
echo "1 = DTRND1"
echo "2 = SCGND1"
echo "3 = SCGND2"
echo "4 = SCGND3"
echo "5 = DTRNL1"
echo "6 = SCGNL1"
echo "7 = SCGNL2"
echo "8 = SCGNL3"
echo "Please enter the number of the instance you want to profile:\c"
read name
case $name in
"1") . /dbhome/dtrnd1/sqllib/db2profile
db2 get instance;;
"2") . /dbhome/scgnd1/sqllib/db2profile
db2 get instance;;
"3") . /dbhome/scgnd2/sqllib/db2profile
db2 get instance;;
"4") . /dbhome/scgnd3/sqllib/db2profile
db2 get instance;;
"5") . /dbhome/dtrnl1/sqllib/db2profile
db2 get instance;;
"6") . /dbhome/scgnl1/sqllib/db2profile
db2 get instance;;
"7") . /dbhome/scgnl2/sqllib/db2profile
db2 get instance;;
"8") . /dbhome/scgnl3/sqllib/db2profile
db2 get instance;;
*) echo "Your did not pick a valid instance";;
esac
What I want to create is one script I can run on any server so I'm attempting to do something similar using the output of db2ilist. I can build the pick list, but I'm not sure how I can use that output to dynamically create a case.
#!/bin/sh
echo "DB2 INSTANCE PROFILER UTILITY"
ilist=$(db2ilist)
i='0'
for instance in $ilist
do
i=`expr $i + 1`
echo $i " = " $instance
done
posted to wrong thread by accident. I apologize. If you feel like you can help please reply to the post in the correct thread