How to get the listener port from its configuration file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get the listener port from its configuration file?
# 1  
Old 01-22-2006
How to get the listener port from its configuration file?

Hi folks,

I'm trying to get the listener port from its configuration file (tnsnames.ora) using sed ,and I encounter difficulties.

tnsnames.ora :
Code:
DB10g =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = buffy)(PORT = 1521))
   (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = DB10g)
   )
 )
 
EXTPROC_CONNECTION_DATA =
 (DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
   )
   (CONNECT_DATA =
     (SID = PLSExtProc)
     (PRESENTATION = RO)
   )
 )

My sed command is:
Code:
DB_LISTENER_PORT=`sed -n '
/process-type id=DESCRIPTION/,/CONNECT_DATA/{ s/PORT=.*\([0-9]\{4\}\)\1/p
}' $ORACLE_HOME/network/admin/tnsnames.ora`

I probably missed someting because $DB_LISTENER_PORT is empty. Smilie

Thanks in advance,
Nir
# 2  
Old 01-22-2006
sorry ...

The command I'm trying to run is:
Code:
root# DB_LISTENER_PORT=`sed -n '
> /DESCRIPTION/,/CONNECT_DATA/{ { s/PORT=.*\([0-9]\{4\}\).*/\1/p
> }' $ORACLE_HOME/network/admin/tnsnames.ora`
Too many {'s

Thanks,
Nir
# 3  
Old 01-22-2006
Too many {'s is what the problem is - double check your opening and closing brackets.

Plus there's no need for the exterior brackets in this case anyway, as you're only executing one sed function.

Code:
$ DB_LISTENER_PORT=`sed -n '/DESCRIPTION/,/CONNECT_DATA/ s/^.*PORT =.*\([0-9]\{4\}\).*$/\1/p' ./tnsnames.ora `
$ echo "$DB_LISTENER_PORT"
1521

Cheers
ZB
# 4  
Old 01-23-2006
Hi ZB,

Thanks a lot!!

Nir
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Modifying listener file

Hi Pros, I'm writing a script to modify listener.ora file on multiple hosts. When I ssh to any server from a central server in our environment we are presented with menu to select the instance. I need to set my environment to listener which could be different number on every instance. How can I... (5 Replies)
Discussion started by: humble_learner
5 Replies

2. Red Hat

Setting serial port configuration

I have 1 serial port (9 Pin) attached with my Linux server.If I give $dmesg | grep tty , it provides me the following. ttyS0 and ttyS1. I have 1 COM port with my server mother board. I have 1 customized application that requires this COM port to be used. The parameter to be set for COM port... (4 Replies)
Discussion started by: Anjan Ganguly
4 Replies

3. Solaris

How to find port number wwn of particular port on dual port HBA,?

please find the below o/p for your reference bash-3.00# fcinfo hba-port HBA Port WWN: 21000024ff295a34 OS Device Name: /dev/cfg/c2 Manufacturer: QLogic Corp. Model: 375-3356-02 Firmware Version: 05.03.02 FCode/BIOS Version: BIOS: 2.02; fcode: 2.01;... (3 Replies)
Discussion started by: sb200
3 Replies

4. UNIX for Dummies Questions & Answers

Listener port

Hi All, I'm installation a server we have client -server architecture I need to configure a port for client to communicate with the server and server to communicate with the clients Pls let me know how to configure in linux (2 Replies)
Discussion started by: gwrm
2 Replies

5. SCO

additional printer port configuration in winxware 7

Dear Sir, How can install additional pci lpt card (parallel port) I want to install second dmp printer in unixware 7 server thanks n regards (2 Replies)
Discussion started by: sudhir69
2 Replies

6. SCO

Serial port configuration

Hi I have just re-installed Compaq ML350 G2 Server with Unix SCO 5.0.5 and informix DBMS . on this server we have 2 serial ports , unfortunately its not working. Can anyone help me to check the serial ports working or not OR guide me to reconfigure it. I have attached a device with... (1 Reply)
Discussion started by: munirh
1 Replies

7. Shell Programming and Scripting

Port Configuration

how do we find Port Configuration in solaris 8/9 telling us whether its used for half duplex or full duplex thanks (1 Reply)
Discussion started by: asadlone
1 Replies

8. Linux

http(port 80) configuration inet file

Hello everybody !! I am new to Linux and need your help. I want to configure http(port 80) in Linux inet file. This will help me give http access to outside users .Could anybody help me in this regard ? Thanks in advance (1 Reply)
Discussion started by: vikasdeshmukh
1 Replies

9. IP Networking

ftp port listener

Hi, Anyone have any pointers on how I would go about creating some sort of listener (preferably, but not exclusively in Java) that would monitor an ftp port and react to arrival of a new file? Thanks in advance. Selma (2 Replies)
Discussion started by: Selma
2 Replies

10. UNIX for Dummies Questions & Answers

serial port configuration

I am having trouble with a device connected through a serial port on my sun workstation ( I am running solaris 7). The seriel device works on an identical workstation running the same o/s version but when I move it to the initial workstation it doesn't work. I am using an rs232 serial cable and... (1 Reply)
Discussion started by: Henrik
1 Replies
Login or Register to Ask a Question