Hello, I have develop a awk script to look into three files.
Here is the problem. It works if for a 2 medium and 1 small input files, but it i use 3 medium files it does not come out.. the out is blank... Do you have any clues why???
see script at the bottom
How the scripts work from command line to the end.
1) cmd - ./nodelist IQSB
2) in frist input file- scripts searches for IQSB then find the node name
3) in second input file - searches for Node name then find the service name.
4) in last input file - searches for service name and prints out IQSB, Node name, and serivce name. I just won the service to be found not any thing that matches it..
first input file looks like (listdb1.txt - 518 lines 15689 characters )
Database 1 entry:
Database alias = IQSB
Database name = IQSB
Node name = ISTSB
Database release level = 9.00
Comment =
Directory entry type = Remote
Catalog node number = -1
Second input file. (node.txt - 141 lines 3743 characters )
Node 13 entry:
Node name = ISTSB
Comment =
Protocol = TCPIP
Hostname = tornsist
Service name = db2isb
last input file (services.txt - 741 lines 23809 characters)
db2isb 12340/tcp
DB2_db2isb 12341/tcp
db2isbi 12344/tcp
Script:
#!/bin/ksh
dblist=listdb1.txt
nodelist=node.txt
servicelist=services.txt
db=$1
awk -v find_db="$db" '
/Database name/ && find_db && $4 == find_db {
db_found = $4;
find_db = 0;
find_db_node = 1;
next;
}
/Node name/ && find_db_node {
node_found = $4;
find_db_node = 0;
find_node = $4;
next;
}
/Node name/ && find_node && $4 == find_node {
find_node = 0;
find_node_serv = 1;
next;
}
/Service name/ && find_node_serv {
service_found = $4;
find_node_serv = 0;
find_service = $4;
next;
}
find_service && $1 == find_service {
print " "
print " ------------"
print " Port Listing"
print " ------------"
print " "
print "Database name = " db_found
print "Node Name = " node_found
Here is the problem. It works if for a 2 medium and 1 small input files, but it i use 3 medium files it does not come out.. the out is blank... Do you have any clues why???
see script at the bottom
How the scripts work from command line to the end.
1) cmd - ./nodelist IQSB
2) in frist input file- scripts searches for IQSB then find the node name
3) in second input file - searches for Node name then find the service name.
4) in last input file - searches for service name and prints out IQSB, Node name, and serivce name. I just won the service to be found not any thing that matches it..
first input file looks like (listdb1.txt - 518 lines 15689 characters )
Database 1 entry:
Database alias = IQSB
Database name = IQSB
Node name = ISTSB
Database release level = 9.00
Comment =
Directory entry type = Remote
Catalog node number = -1
Second input file. (node.txt - 141 lines 3743 characters )
Node 13 entry:
Node name = ISTSB
Comment =
Protocol = TCPIP
Hostname = tornsist
Service name = db2isb
last input file (services.txt - 741 lines 23809 characters)
db2isb 12340/tcp
DB2_db2isb 12341/tcp
db2isbi 12344/tcp
Script:
#!/bin/ksh
dblist=listdb1.txt
nodelist=node.txt
servicelist=services.txt
db=$1
awk -v find_db="$db" '
/Database name/ && find_db && $4 == find_db {
db_found = $4;
find_db = 0;
find_db_node = 1;
next;
}
/Node name/ && find_db_node {
node_found = $4;
find_db_node = 0;
find_node = $4;
next;
}
/Node name/ && find_node && $4 == find_node {
find_node = 0;
find_node_serv = 1;
next;
}
/Service name/ && find_node_serv {
service_found = $4;
find_node_serv = 0;
find_service = $4;
next;
}
find_service && $1 == find_service {
print " "
print " ------------"
print " Port Listing"
print " ------------"
print " "
print "Database name = " db_found
print "Node Name = " node_found