tnsping mydb
where mydb corresponds to the tnsnames.ora alias of interest.
* If there was an error, exit script.
* If listener was up, continue.
I directed the output to a file, and after that grepped for the string that would indicate success or failure.
Problem was that the files would look very different and the interesting string would need to be grepped for using two different delimiters.
When successful, the file would look as follows:
OK (10 msec)
When not successful, the output would be:
TNS-03505: Failed to resolve name
So how to pull out either "TNS" or "OK" and use these values programmatically further on in the script?
I accomplished this task simply by using the notation '[-(]'in my awk statement:
REMOTE_LSNR_STATUS=`cat ${LOG_DIR}/test_tnsping.log | egrep -e 'TNS-|OK' | awk -F '[-(]' '{ print $1 }'`
No comments:
Post a Comment