Sponsored Content
Full Discussion: How to extract port number?
Top Forums Shell Programming and Scripting How to extract port number? Post 302766495 by jediwannabe on Monday 4th of February 2013 10:54:38 PM
Old 02-04-2013
How to extract port number?

Hi my code is as follow:

Code:
stringA=`cat /s01/oracle/11.2/network/admin/listener.ora | grep "PORT"`
stringB=`cat $ORACLE_HOME/network/admin/listener.ora | grep "PORT"`
stringC="PORT"

echo ${stringA}
echo ${stringB}
echo ${stringC}

position=`expr index "$stringB" "stringC"`

echo ${position}

output is as follow
Code:
(DESCRIPTION_LIST =(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SG-RH5.3-64)(PORT=1522)))
(DESCRIPTION_LIST =(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SG-RH5.3-64)(PORT=1522)))
PORT
7

But unfortunately I don't understand why position 7 is return and if position 7 is returned, I definitely cannot extract 1522 as port number, i.e. $port_number=1522

I'm running on Redhat 5.3

Code:
Red Hat Enterprise Linux Server release 5.3 (Tikanga)

thanks
 

10 More Discussions You Might Find Interesting

1. Cybersecurity

get number of a port

Hello every one. I work in a LAN with many application server. Each one use a different port. What command permit to obtain the number of these port. thanks (2 Replies)
Discussion started by: hoang
2 Replies

2. UNIX for Dummies Questions & Answers

how to know whether particular port number is free or not

I wish to know whether a particular port is free or not in my SUN solaris SPARC machine . I wish to use that particular port for one server software. How do I know that. (2 Replies)
Discussion started by: Hitesh Shah
2 Replies

3. UNIX for Advanced & Expert Users

FTP Port Number

On HP-UX 11 how do I get the port number of an active ftp connection? (2 Replies)
Discussion started by: mbb
2 Replies

4. Shell Programming and Scripting

port number as an argument

What is the script that takes a port number as parameter and displays status, whether it is available or is already used by other process pls help (1 Reply)
Discussion started by: saikiran
1 Replies

5. UNIX for Dummies Questions & Answers

Need to know port number

Hi expert, I wanted to know in which port my apache is running in solaris box thanks Shaan (1 Reply)
Discussion started by: shaan_dmp
1 Replies

6. UNIX for Dummies Questions & Answers

port number

hi all i want to connect a system, how can i know the port number of a system. (2 Replies)
Discussion started by: tukuna82
2 Replies

7. Solaris

Finding port number !!

Hi all , I want know the port no on which a particular application is running. How to find that? Thanks in anticipation (11 Replies)
Discussion started by: kumarmani
11 Replies

8. UNIX for Advanced & Expert Users

Port number file

In which file inside the application code we can find the list of port numbers that the application is entitled to listen? (4 Replies)
Discussion started by: p_gautham12
4 Replies

9. Shell Programming and Scripting

Extract terminal ip and port from line

HI, I have a line conn console {conntype=serial;connhost=122.25.000.220;connport=6038;password=123!} and i am using the below code to extract the ip. while read line do if echo "$line" | grep "connhost" >/dev/null 2>&1 then echo $line TERM=`echo... (8 Replies)
Discussion started by: asak
8 Replies

10. 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
TRACE-CMD-LISTEN(1)													       TRACE-CMD-LISTEN(1)

NAME
trace-cmd-listen - listen for incoming connection to record tracing. SYNOPSIS
trace-cmd listen -p port [OPTIONS] DESCRIPTION
The trace-cmd(1) listen sets up a port to listen to waiting for connections from other hosts that run trace-cmd-record(1) with the -N option. When a connection is made, and the remote host sends data, it will create a file called trace.HOST:PORT.dat. Where HOST is the name of the remote host, and PORT is the port that the remote host used to connect with. OPTIONS
-p port This option will specify the port to listen to. -D This options causes trace-cmd listen to go into a daemon mode and run in the background. -d dir This option specifies a directory to write the data files into. -o filename This option overrides the default trace in the trace.HOST:PORT.dat that is created when a remote host connects. -l filename This option writes the output messages to a log file instead of standard output. SEE ALSO
trace-cmd(1), trace-cmd-record(1), trace-cmd-report(1), trace-cmd-start(1), trace-cmd-stop(1), trace-cmd-extract(1), trace-cmd-reset(1), trace-cmd-split(1), trace-cmd-list(1) AUTHOR
Written by Steven Rostedt, <rostedt@goodmis.org[1]> RESOURCES
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git COPYING
Copyright (C) 2010 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL). NOTES
1. rostedt@goodmis.org mailto:rostedt@goodmis.org 06/11/2014 TRACE-CMD-LISTEN(1)
All times are GMT -4. The time now is 12:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy