I've been working on a script to delete an environment including the Oracle db. I've got everything working except for automating the cleanup of tns entries. I was originally thinking it would be easy enough with regexp but since I've noticed different formats of the entries between different nodes I'm not sure what patterns to look for. Is there a decent way to handle automating the cleanup of tnsnames.ora when a db is deleted on unix boxes?
Asked
Active
Viewed 871 times
1 Answers
2
For C#, I have been using a RegEx from: http://www.codeproject.com/Articles/30962/TNSNames-Reader
If you're running the following ReGex against TNSNAMES.ORA, you get a list of the databases. ([\n][\s]*[^(][a-zA-Z0-9_.]+[\s])=[\s](
You use the first MatchGroup of each item and run TNSPING against it. If it responds, you keep the entry - if it doesn't - you discard the entry.
The downside is - if a db is down just at this moment - you will clean it out of tnsnames anyway...

Tobias Twardon
- 509
- 4
- 4