Sponsored Content
Top Forums Shell Programming and Scripting Sending sqlplus output to a shell variable Post 302745559 by beginer314 on Monday 17th of December 2012 02:04:48 PM
Old 12-17-2012
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 03:10 PM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help me in sending parameters from sqlplus script to unix shell script

Can anybody help me out in sending parameters from sql*plus script to unix shell script without using flat files.. Initially in a shell script i will call sql*plus and after getting some value from some tables, i want that variable value in unix shell script. How can i do this? Please tell me... (2 Replies)
Discussion started by: Hara
2 Replies

2. UNIX for Dummies Questions & Answers

select count(*) in sqlplus into variable unix shell

Need to select count(*) from table to check for zero result in unix script (2 Replies)
Discussion started by: struggle
2 Replies

3. Shell Programming and Scripting

error in passing a variable to sqlplus from a shell script

hi, I am using a shell script from where i will be conecting to sqlplus.. i am having a problem in passing a variable to sqlplus query.. i will be assigning the variable in the unix environment..whenever i am trying to pass a variable having the contents greater than 2500 characters, i am... (3 Replies)
Discussion started by: kripssmart
3 Replies

4. Shell Programming and Scripting

store sqlplus output in variable

hi how can i store sqlplus output to a variable in sh script (not bash) Thanks MM (1 Reply)
Discussion started by: murtymvvs
1 Replies

5. Shell Programming and Scripting

(solved) Shell scripting to access SQLPLUS using variable

I have shell script which will try to login to SQL Plus and retrieve some data, based on the outcome i will proceed further Below is the content of the file pebblz02% cat test1.ksh #! /bin/ksh dummyvar=`sqlplus -S csm_admin/csm_admin@SIDNAME <<EOF echo hi; exit; EOF` Error message on... (0 Replies)
Discussion started by: kiranlalka
0 Replies

6. Shell Programming and Scripting

Log sqlplus output from Shell

UNIX Gods, I'll be running this script from CRON. I need to log the status of each of the six sqlplus calls into a file when this job is kicked off. Any suggestions? Thanks in advance. #!/bin/ksh export USAGE="USAGE: `basename $0` -e <DBUSER> <DBPASSWD> <TNSNAME>" if ; then ... (2 Replies)
Discussion started by: WhoDatWhoDer
2 Replies

7. Shell Programming and Scripting

Problems with storing oracle sqlplus query output shell script

Hello everyone, I have a RHEL 5 system and have been trying to get a batch of 3-4 scripts each in a separate variables and they are not working as expected. I tried using following syntax which I saw a lot of people on this site use and should really work, though for some reason it doesn't... (3 Replies)
Discussion started by: rockf1bull
3 Replies

8. Shell Programming and Scripting

Sending Sed/Echo output to Variable

I have a variable $WORDS that contains a string Then i want to use sed to break it up. echo $WORDS | sed 's// /g' I tried setting this as a variable by doing WORDS2=`echo $WORDS | sed 's// /g'` But when i do this it does not return me to the prompt properly ie. jmpprd-v1> jmpprd-v1>... (4 Replies)
Discussion started by: nitrobass24
4 Replies

9. Shell Programming and Scripting

How to pass Variable from shell script to select query for SqlPlus?

echo "set echo off"; echo "set feedback off"; echo "set linesize 4000"; echo " set pagesize 0"; echo " set sqlprompt ''"; echo " set trimspool on"; Select statement is mentioned below echo "select res.ti_book_no from disney_ticket_history res where res.ti_status =${STATUS} and... (7 Replies)
Discussion started by: aroragaurav.84
7 Replies

10. Shell Programming and Scripting

Passing sqlplus output to shell variable

Hi , I am using below code : for i in `ps -ef|grep pmon|awk {' print $8 '}|cut -f3 -d'_'|grep -v '^grep'` do ORACLE_SID=$i export ORACLE_SID; dest=`sqlplus "/ as sysdba" <<EOF set heading off feedback on verify off select DESTINATION from v\\$archive_dest where target in... (5 Replies)
Discussion started by: admin_db
5 Replies
shell(1F)							   FMLI Commands							 shell(1F)

NAME
shell - run a command using shell SYNOPSIS
shell command [command] ... DESCRIPTION
The shell function concatenate its arguments, separating each by a space, and passes this string to the shell ($SHELL if set, otherwise /usr/bin/sh). EXAMPLES
Example 1 A sample output of shell command. Since the Form and Menu Language does not directly support background processing, the shell function can be used instead. `shell "build prog > /dev/null &"` If you want the user to continue to be able to interact with the application while the background job is running, the output of an exe- cutable run by shell in the background must be redirected: to a file if you want to save the output, or to /dev/null if you don't want to save it (or if there is no output), otherwise your application may appear to be hung until the background job finishes processing. shell can also be used to execute a command that has the same name as an FMLI built-in function. NOTES
The arguments to shell will be concatenate using spaces, which may or may not do what is expected. The variables set in local environments will not be expanded by the shell because "local" means "local to the current process." ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
sh(1), attributes(5) SunOS 5.11 5 Jul 1990 shell(1F)
All times are GMT -4. The time now is 08:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy