cougartrace
Technical User
I have a script that does DB2 HADR monitoring, however during execution it asks me for the user password - is there anyway to pass that password in the script?
DB2HADRDBNAME=TDWD
#Get the local DB2 instance name
DB2INST=db2tdwd
HADRROLE="UNKNOWN"
HADRSTAT="UNKNOWN"
HADRROLE=$(su - $DB2INST -c "db2pd -hadr -db $DB2HADRDBNAME" |grep -p "HADR Information" |grep -v HADR |grep -v Role | awk '{print $1}')
HADRSTAT=$(su - $DB2INST -c "db2pd -hadr -db $DB2HADRDBNAME" |grep -p "HADR Information" |grep -v HADR |grep -v Role | awk '{print $2}')
if [[ $? = "0" ]];
then
echo "Info: $DB2HADRDBNAME ROLE IS $HADRROLE,
state is in $HADRSTAT state"
exit 0
else
echo "ERROR: CAN NOT GET INFORMATION FOR
$DB2HADRDBNAME "
exit 1
fi
DB2HADRDBNAME=TDWD
#Get the local DB2 instance name
DB2INST=db2tdwd
HADRROLE="UNKNOWN"
HADRSTAT="UNKNOWN"
HADRROLE=$(su - $DB2INST -c "db2pd -hadr -db $DB2HADRDBNAME" |grep -p "HADR Information" |grep -v HADR |grep -v Role | awk '{print $1}')
HADRSTAT=$(su - $DB2INST -c "db2pd -hadr -db $DB2HADRDBNAME" |grep -p "HADR Information" |grep -v HADR |grep -v Role | awk '{print $2}')
if [[ $? = "0" ]];
then
echo "Info: $DB2HADRDBNAME ROLE IS $HADRROLE,
state is in $HADRSTAT state"
exit 0
else
echo "ERROR: CAN NOT GET INFORMATION FOR
$DB2HADRDBNAME "
exit 1
fi