If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Need Shell Script for displaying Instances,databases,dbalias and port number

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-04-09, 08:45
sekhar bade sekhar bade is offline
Registered User
 
Join Date: Nov 2009
Posts: 9
Need Shell Script for displaying Instances,databases,dbalias and port number

Hi,
I need a shell script for displaying instance names,database names and database alias names which are presenting in a particular instance(only Local databases) and port numbers in a tabular form.I had written a shell script for this but it is not displaying all alias names for databases(only 1st alias name its showing).If anybody is having it already please help me.

I'm showing the structure by indenting but we just need a flat file generated in table-like format:

> Server Name and IP Address
- DB2 Instance Name and Port Number
+ Database Name and Alias
+ Database Name and Alias
+ etc

- Next DB2 Instance Name and Port Number
+ Database Name and Alias
+ etc
- Etc...

Thanks&Regards

Bade
Reply With Quote
  #2 (permalink)  
Old 11-04-09, 09:05
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Can you post the script please ? Also specify where you are facing the problem.


Cheers
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 11-04-09, 09:56
sekhar bade sekhar bade is offline
Registered User
 
Join Date: Nov 2009
Posts: 9
Hi Satyaram thanks for ur quick reply

I'm executing the below command :
1. db2 list db directory

Output:

Database 1 entry:

Database alias = SAMP
Database name = SAMPLE
Local database directory = /db2samp1
Database release level = b.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =

Database 2 entry:

Database alias = DBWEB
Database name = DBWEB
Local database directory = /db2samp1
Database release level = b.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =

Database 3 entry:

Database alias = DBPORT
Database name = DBPORT
Local database directory = /db2samp1
Database release level = b.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =

Database 2 entry:

Database alias = SAMPLE
Database name = SAMPLE
Local database directory = /db2samp1
Database release level = b.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =



Basing on "Local database directory" of the above output, i'm executing the below command:

2. db2 list db directory on /db2samp1 | egrep -i -e "Database alias"

Output:

DBWEB
DBPORT
SAMPLE


Here it should also display the SAMP database alias name but it is not displaying that alias.

Thanks in advance
Bade
Reply With Quote
  #4 (permalink)  
Old 11-04-09, 10:32
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Code:
db2 list db directory | grep -p Indirect | egrep -i -e "Database alias"
will do the trick
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 11-06-09, 06:13
sekhar bade sekhar bade is offline
Registered User
 
Join Date: Nov 2009
Posts: 9
Thanks Sathyaram
It really help me a lot in modifying the script.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On