Link to home
Start Free TrialLog in
Avatar of peledc
peledc

asked on

ssh with special character to sqlplus

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...
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

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).
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?
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could also try 1 (or 3) backslashes between the << and the EOF (immediately before the E of EOF).
Avatar of peledc
peledc

ASKER

This worked \\\\\\

Thanks...