Get the tnsnames.ora alias for a given service name
Hello,
puzzling me now way to long....so hopefully someone has the answer at hand:
The following shows a sample tnsnames.ora from another topic.
What I want to get as result the tnsnames alias "PRI" when searching for the service name pri.
That is, the left hand side of the tnsnames entry where the service name 'pri' is used.
Preferably shell script or sed.
any help appreciated
tags: linux, tnsnames, tnsname alias, service name
Last edited by kpg; 04-24-2020 at 10:44 AM..
Reason: missed tags - but how do i add tehm?
Hi,
thanks for the awk --- I do not understand how it should work and I get an error I can not correct:
And I'd like to search for a service name that contains 'pri'. Can you please explain?
I played around with sed:
returns all lefthand sides of the tnsnames.ora....if only I could add something to match the DESCRIPTION with a service name matching 'pri'
thanks again for giving me the time to find out what to correct...I now run
...and it matches just fine. How do I make it case insensitive? Can you please explain how it works?
I think the first line skips over the tnsnames.ora until it finds a pattern 'variable ='. So this will give us the left hand side in $1?
The second line searches for the SERVICE_NAME entry, where the value matches s, which is set on the command line to be 'pri'.
You store this in $1 ....but didn't we keep the left hand side there?
I think the first line skips over the tnsnames.ora until it finds a pattern 'variable ='. So this will give us the left hand side in $1?
The second line searches for the SERVICE_NAME entry, where the value matches s, which is set on the command line to be 'pri'.
You store this in $1 ....but didn't we keep the left hand side there?
... I do not understand the third line at all.
I forgot that ( is special in ERE, that awk uses. You found it: needs to be escaped. An alternative would be [(].
Each code line is a condition { action }.
All three code lines are run for each input line.
If the condition in the 2nd code line is true it performs the action: print variable a.
This is set in the 3rd code line to field#1, if it does not have a ( at the beginning.
Hi,
User claim that job is running slow from their end.
I DBA found in database the below errors in alert log file.
ORA-27603: Cell storage I/O error, I/O failed on disk o/192.168.10.3/RECO_DM01_CD_01_drm01 at offset 13335789568 for data length 1048576
ORA-27626: Exadata error: 2201 (IO... (2 Replies)
Hi,
I am trying to write a script or command to remove a section from tnsnames.ora file
in the following example I would like to remove tns_alias2 section
$ cat tnsnames.ora
tns_alias1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = host1 )(PORT = 1521))
... (3 Replies)
Hi,
I would like to modify, in script schell, the line right above (DESCRIPTION and check three cases :
if line contain ".world" then line=line-".world" concat "," concat line
if line dont contain ".world" then line=line concat "," concat line concat".world"
else line=line
Keep in... (10 Replies)
Hi - I am trying to grep all "ORA" errors in a log files.I have to grep all ORA errors except one error for example ORA-01653.How can exclude that error in "grep" command?
In following "grep" command I want to exclude "ORA-01653" error
grep -i ORA alert.log >>/tmp/ora_errors.txt
... (7 Replies)
All:
Can sombodoy help me out with a sed command? Assume I have the following:
PRI =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.3.7)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pri)
... (3 Replies)
Hi all,
Am intermittently getting the following errors on one of my databases.
Errors in file /oracle/HRD/saptrace/background/hrd_psp0_13943.trc:
ORA-27300: OS system dependent operation:fork failed with status: 12
ORA-27301: OS failure message: Not enough space
ORA-27302:... (1 Reply)
Hi everyone,
when i run ;
sqlplus -s username/password@TTTEST @umt.sql
i take "ORA-12154: TNS:could not resolve service name"
i want to run "umt.sql" query and also see result.
thanx for your helping. (6 Replies)