[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ssh with special character to sqlplus

Posted on 2014-07-13
5
Medium Priority
?
518 Views
Last Modified: 2014-07-14
Hi,

In Linux RHEL 5.6
I'm trying to execute a SQL statement inside Oracle on a remote host.
My query is using the v$parameter and I'm having problems passing the $(dollar sign).

My code:
RESULT=`ssh 10.0.0.3  "setenv ORACLE_SID $PRIMARY_ORACLE_SID; sqlplus -s / as sysdba << EOF
    select value from v$parameter where name='dg_broker_start';
EOF"`
> echo RESULT=$RESULT
 
 RESULT= select value from v where name='dg_broker_start'

I tried "v$parameter"
and      v\$parameter
and    "v\$parameter"

none of the above worked.
Only the V is left...
0
Comment
Question by:peledc
5 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40193035
You'll have to use at least two backslashes for escaping - the $ sign must be protected from being expanded by the local shell as well as from the remote shell.

If two backslasehs don't work either try three of them (at least I once had to do so to make it work).
0
 
LVL 81

Expert Comment

by:arnold
ID: 40193048
if I'm not mistaken, you may have to use v\\\$
the first will be drawn down to v\$

If this is a common query, why not setup a script on the remote end to which you will be passing data points?
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 40193063
Three backslashes are not sufficient for ssh/sqlplus between backticks.

Try  v\\\\\\$parameter

No joke!
0
 
LVL 20

Expert Comment

by:simon3270
ID: 40193152
You could also try 1 (or 3) backslashes between the << and the EOF (immediately before the E of EOF).
0
 
LVL 1

Author Closing Comment

by:peledc
ID: 40193865
This worked \\\\\\

Thanks...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Suggested Courses
Course of the Month19 days, 17 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question