![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| rm & mv command failed due to too many files. | videsh77 | UNIX for Advanced & Expert Users | 9 | 05-16-2008 11:01 AM |
| Problem with Mail command: exec failed. errno=2. | hawkman2k | UNIX for Dummies Questions & Answers | 1 | 04-29-2008 06:50 AM |
| Fatal error: Command failed for target `build_crypto' | sayed_021 | SUN Solaris | 1 | 02-13-2008 08:16 AM |
| Solaris 9: make: Fatal error:Command failed for target | eldiego | UNIX for Dummies Questions & Answers | 2 | 10-28-2005 12:11 PM |
| Editing file during running ksh in HP failed | nir_s | Shell Programming and Scripting | 2 | 08-05-2004 05:50 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Failed to get value from a file using sed command
Hi folks,
I have the following file (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)
)
)
Code:
buffy:/tmp # echo $CONNECT_STRING
DB10g
buffy:/tmp # echo $ORACLE_HOME
/home/oracle/v10.1.0
buffy:/tmp # export DB_LISTENER_PORT=`sed -n '/"'"${CONNECT_STRING}"'"/,/CONNECT_DATA/ s/^.*PORT =.*\([0-9]\{4\}\).*$/\1/p' $ORACLE_HOME/network/admin/tnsnames.ora `
buffy:/tmp # echo $DB_LISTENER_PORT
But if I replace the parameter $CONNECT_STRING with hard-coded value ,it will work: Code:
buffy:/tmp # export DB_LISTENER_PORT=`sed -n '/DB10g/,/CONNECT_DATA/ s/^.*PORT =.*\([0-9]\{4\}\).*$/\1/p' $ORACLE_HOME/network/admin/tnsnames.ora `
buffy:/tmp # echo $DB_LISTENER_PORT
1521
Thanks in advance, Nir |
| Forum Sponsor | ||
|
|