|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | 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 and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Sending sqlplus output to a shell variable
I am trying to import a sqlplus output into a shell variable but it doesnt seem to be working. Code:
set -x export DEPENDENT_CR_NO=`sqlplus -s /nolog <<EOF conn username/passwd set heading off select dependency from custom_patches where patch_name='PATCH.zip'; exit; EOF` echo $DEPENDENT_CR_NO if [[ $DEPENDENT_CR_N0 = '' ]] then echo "there is no dependency" else echo "DEPENDENCY IS $DEPENDENT_CR_N0" fi Below is the output from the above script Code:
+ sqlplus -s /nolog + 0<< \EOF conn username/psswd set heading off select dependency from custom_patches where patch_name='PATCH.zip'; exit; EOF + DEPENDENT_CR_NO=$'\n56240; 56242' + export DEPENDENT_CR_NO + echo '56240;' 56242 56240; 56242 + [[ '' == '' ]] + echo 'there is no dependency' there is no dependency I am not sure why $DEPENDENT_CR_NO is coming up null in the if loop. Thanks Last edited by Scott; 12-17-2012 at 02:10 PM.. Reason: Please use code tags |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Hi. You have DEPENDENT_CR_NO (with Oh) and DEPENDENT_CR_N0 (with zero). Code:
export DEPENDENT_CR_NO=`sqlplus -s /nolog <<EOF conn username/passwd set heading off select dependency from custom_patches where patch_name='PATCH.zip'; exit; EOF` echo $DEPENDENT_CR_NO if [[ $DEPENDENT_CR_N0 = '' ]] then ... Your test will also fail because without set feedback off, the variable will always contain text. |
| The Following User Says Thank You to Scott For This Useful Post: | ||
beginer314 (12-17-2012) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks Scott, that was a stupid mistake i made. Thanks for the quick reply.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sending Sed/Echo output to Variable | nitrobass24 | Shell Programming and Scripting | 4 | 08-28-2012 04:25 PM |
| Log sqlplus output from Shell | WhoDatWhoDer | Shell Programming and Scripting | 2 | 06-15-2011 11:26 AM |
| store sqlplus output in variable | murtymvvs | Shell Programming and Scripting | 1 | 12-04-2010 12:46 PM |
| error in passing a variable to sqlplus from a shell script | kripssmart | Shell Programming and Scripting | 3 | 07-08-2008 07:01 PM |
| help me in sending parameters from sqlplus script to unix shell script | Hara | Shell Programming and Scripting | 2 | 01-29-2008 02:31 PM |
|
|