Computing.Net > Forums > Linux > here doc interpolate values

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

here doc interpolate values

Reply to Message Icon

Name: Jumper
Date: June 22, 2007 at 03:45:54 Pacific
OS: Red Hat Enterprise Linux
CPU/Ram: CPU Speed: 2600
Product: ProLiant DL585 G2
Comment:


Hi,

the following sql call works in a shell returning the value I expect in a form that I expect after logging into sqlplus.

SELECT pck_crypto.decrypt(uss.ftp_password) FROM up_stream_systems uss WHERE LOWER(uss.ftp_user) = 'ftpbsmsl';


Putting it into the following script does not.

#!/bin/bash

if [ $# != 1 ]
then
echo "'$0 $*' Invalid"
echo "USAGE: $0 parameter1";
exit 1
fi

tst_USER=$1

echo $tst_USER

PMC_PASSWORD=`sqlplus -s / << PMC
SET HEADING OFF
SELECT pck_crypto.decrypt(uss.ftp_password)
FROM up_stream_systems uss
WHERE LOWER(uss.ftp_user) = ${tst_USER}
EXIT
PMC`

if [ ${PMC_PASSWORD} ]
then
echo $PMC_PASSWORD
else
echo "No rows returned from database"
fi


How can I preserve the single quotes around the value that sql needs to test against the column in the here doc?


tia,



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: June 22, 2007 at 04:39:35 Pacific
Reply:

I haven't used Red Hat in a long, long time, but try using \' for your inside quotes.


0

Response Number 2
Name: Jumper
Date: June 22, 2007 at 08:05:23 Pacific
Reply:

thanks Razor, that's ideal


:)


0

Response Number 3
Name: ernie
Date: June 22, 2007 at 08:41:49 Pacific
Reply:

Since bash recognizes the \ (backslash character) as an escape character this should work in any distribution that uses bash as the default command interpreter.

Ernie Registered Linux User 247790
ICQ 41060744


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: here doc interpolate values

Interview Questions www.computing.net/answers/linux/interview-questions/30414.html

Anybody, I REALLY need advice!! www.computing.net/answers/linux/anybody-i-really-need-advice/6621.html

internet security for squid www.computing.net/answers/linux/internet-security-for-squid/23142.html