문제

Is there an API that will read a TNS file and present it in some easy-to-use data structure?

I would like to get a list of all my TNS entries. This works but is not particularly elegant!

grep '^[a-zA-Z].*=' /etc/tnsnames.ora | sed 's/[ =].*//'
도움이 되었습니까?

해결책

Another, not very simple, solution is ANTLR. You can use ANTLR to parse tnsnames.ora. On ANTLR Grammar List page you will find grammar which can parse tnsnames.ora, sqlnet.ora and listener.ora

다른 팁

I'm not sure if TNSPing would be more useful to you. It will output like:

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production
on 01-MAR-2009 02:02:33

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)
(HOST = myhostname)(PORT = 1521)) (CONNECT_DATA = (SID = mydb)))
OK (80 msec)

The problem is you must pass it the TNS name to ping, which may or may not be possible in your scenario.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top