Sponsored Content
Operating Systems Linux Red Hat Dynamic case creation based on output list from a command Post 302655691 by slatoms on Wednesday 13th of June 2012 02:11:48 PM
Old 06-13-2012
Dynamic case creation based on output list from a command

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.


Code:
#!/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.

Code:
#!/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

https://www.unix.com/shell-programmin...#post302655695

Last edited by slatoms; 06-13-2012 at 03:23 PM.. Reason: posted to wrong thread
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creation of log file under dynamic date folder

HI I want to create a date folder and then a log file under it, which will hold all output of shell script. Say shell script abc.sh runs every day and I want to redirect the output of abc.sh > /opt/bea/wls81/Pkmtest/$(date +%Y%m%d)/ant.log. Here date should always change according to system... (2 Replies)
Discussion started by: pankajkrmishra
2 Replies

2. Shell Programming and Scripting

Creation of output file from list of file

Hi Guru's, Eventhough I know basic shell scripting, Iam not an expert. Can any one help me to get a logic/answer for the below requirement: I've to create an output file "outputfile.txt" from many datafiles (ex: abc.dat, xyz.dat). Header record layout for "outputfile.txt" should be... (7 Replies)
Discussion started by: ganapati
7 Replies

3. Shell Programming and Scripting

Creating a dynamic case statement

I'm using the korn shell and trying to create a case statement from the contents of a file that is changed regularly, each line of the file has three fields, eg track1 202.111.111.111 99 room7 222.111.222.333 76 I'm using awk to select each variable. I've been unable to figure out how to... (5 Replies)
Discussion started by: squrcles
5 Replies

4. UNIX for Advanced & Expert Users

Dynamic file creation

This my script ls *.ksh ls *.ksh > a.txt i=1 cat "a.txt" | while read a do if then echo "abc" echo "abc" > m.ksh echo "m.ksh" >> a.txt i=2 fi echo $a done ls *.ksh -------------------------- My Output is a.ksh - > first ls *.ksh (1 Reply)
Discussion started by: kingganesh04
1 Replies

5. Shell Programming and Scripting

Parsing dynamic data from a command output

Hi people, I am writing a korn shell script, and one of the command gives an output something like below: release.label.2010.03.02 objects: /project/path/to/some/file_name.ksh /project/path/another/file_name01.dat I have to retrieve the file paths one by one & use them as... (9 Replies)
Discussion started by: kiwin1000
9 Replies

6. Shell Programming and Scripting

Conversion from Upper Case to Lower Case Condition based

Hello Unix Gurus : It would be really appreciative if can find a solution for this . I have records in a file . I need to Capitalize the records based on condition . For Example i tried the following Command COMMAND --> fgrep "2000YUYU" /export/home/oracle/TST/data.dat | tr '' ''... (12 Replies)
Discussion started by: tsbiju
12 Replies

7. Shell Programming and Scripting

Dynamic case creation based on output list from a command

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

8. Red Hat

Command understanding the output file destination in case of standard output!!!!!

I ran the following command. cat abc.c > abc.c I got message the following message from command cat: cat: abc.c : input file is same as the output file How the command came to know of the destination file name as the command is sending output to standard file. (3 Replies)
Discussion started by: ravisingh
3 Replies

9. UNIX for Dummies Questions & Answers

Select all files in a folder based on creation date (ls command)

Hi All, <Re-posting in Correct group> I'm trying to select all the files in a folder that starts with a particular name format and are created in a gven date range using 'ls' command...but i'm not successful.... Example : I'm trying to see all the text files in a folder who names start... (6 Replies)
Discussion started by: Satya C1
6 Replies

10. UNIX for Dummies Questions & Answers

Dynamic Variable creation

I am trying to create some variables based on the input by the user, say if user entered 3 then 3 variables and if 5 then 5 variables. I am using a for loop for (( i=1; i <= $num; i++ )) do x="num" x+=$i done When i am using echo $x it will show num1 but now how to create variables... (3 Replies)
Discussion started by: Raj999
3 Replies
BOS_STARTUP(8)						       AFS Command Reference						    BOS_STARTUP(8)

NAME
bos_startup - Starts a process without changing its status flag SYNOPSIS
bos startup -server <machine name> [-instance <instances>+] [-cell <cell name>] [-noauth] [-localauth] [-help] bos startu -s <machine name> [-i <instances>+] [-c <cell name>] [-n] [-l] [-h] DESCRIPTION
The bos startup command starts, on the server machine named by the -server argument, either: o All AFS server processes not currently running but marked with the "Run" status flag in the /etc/openafs/BosConfig file. o Each process specified by -instance argument, even if its status flag in the BosConfig file is "NotRun". To start a process and set its BosConfig status flag to "Run", use the bos start command instead. OPTIONS
-server <machine name> Indicates the server machine on which to start processes. Identify the machine by IP address or its host name (either fully-qualified or abbreviated unambiguously). For details, see bos(8). -instance <instances>+ Names each process to start. Use the process name assigned with the -instance argument to the bos create command. The output from the bos status command lists the names. -cell <cell name> Names the cell in which to run the command. Do not combine this argument with the -localauth flag. For more details, see bos(8). -noauth Assigns the unprivileged identity "anonymous" to the issuer. Do not combine this flag with the -localauth flag. For more details, see bos(8). -localauth Constructs a server ticket using a key from the local /etc/openafs/server/KeyFile file. The bos command interpreter presents the ticket to the BOS Server during mutual authentication. Do not combine this flag with the -cell or -noauth options. For more details, see bos(8). -help Prints the online help for this command. All other valid options are ignored. EXAMPLES
The following command starts all processes marked with status flag "Run" in the BosConfig file on the machine "fs3.abc.com" that are not currently running. % bos startup fs3.abc.com The following command starts the buserver, kaserver, ptserver, and vlserver processes running on the machine "db2.abc.com", even if their status flags in the BosConfig file are "NotRun". % bos startup -server db2.abc.com -instance buserver kaserver ptserver vlserver PRIVILEGE REQUIRED
The issuer must be listed in the /etc/openafs/server/UserList file on the machine named by the -server argument, or must be logged onto a server machine as the local superuser "root" if the -localauth flag is included. SEE ALSO
BosConfig(5), KeyFile(5), UserList(5), bos(8), bos_create(8), bos_start(8), bos_status(8) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2012-03-26 BOS_STARTUP(8)
All times are GMT -4. The time now is 07:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy