I'm trying to list the port numbers of all the instances in a server, using the below script. But it is not working can anyone help. If any of the listed instances are not working and throwing a db2 error then the remaining instances port numbers are also not displayed.
The db2 error i'm getting is SQL10007N Message "-1090" could not be retrieved. Reason code: "3".
db2ilist > /tmp/instance.list
while read line
if [ -e /home/$line/sqllib/db2profile ]; then
## Checks if any integer (50000) value is specified in SVCENAME ##
echo $(head -1 /tmp/serv.list) | egrep '^[0-9]+$' >/dev/null 2>&1
if [ "$?" -eq "0" ]; then ## If SVCENAME is an integer retrieving the port number using the instance name to search from /etc/servies file##
grep -w $line /etc/services >> /tmp/port.list
else ## If SVCENAME is a string retrieving the port number using the SVCENAME to search from /etc/servies file ##
grep -w $(head -1 /tmp/serv.list) /etc/services >> /tmp/port.list
db2 "terminate" > /tmp/msg.list