0

I'm Running some SQLPLUS code over ssh.

ssh -q node1 'export ORACLE_SID=DB11D_1;ORAENV_ASK=NO;. oraenv >/dev/null 2>&1;sqlplus -s / as sysdba  << ENDSQL
whenever sqlerror exit 1
alter system set wallet open identified by "Passwo$1";
exit;
ENDSQL'

It looks like the $1 in the password "Passwo$1" gets substituted. And that's causing the command to fail.

The command ends up turning into alter system set wallet open identified by "Passwo" *

ERROR at line 1:
ORA-28353: failed to open wallet

Any idea how do I preserve the "$1" in the SQLPLUS command?

I have tried the below

- alter system set wallet open identified by \"Passwo$1\";
- alter system set wallet open identified by \\\"Passwo$1\\\";
- alter system set wallet open identified by '\""Passwo$1""\';

I cannot add an escape to the $ symbol in the password. So I can't do

- alter system set wallet open identified by "Passwo\$1";

Thanks

1

In the here-document that you pass to sqlplus, either escape the $ as \$ (it is unclear why you say that you can't do this in the question), or quote the whole here-document by using <<'ENDSQL' or <<\ENDSQL (this may be preferable if you have nothing else in the here-document that needs expanding).

Additionally, the string Passwo$1 has to be single quoted in the here-document. Since the document is a shell script, the string still has to be protected from the shell that interprets it. You do this by writing it as 'Passwo$1'.

  • Hi. Thanks.I have tried your solution. Hope I'd doing it right, as it still seems to substitute the $1 part of the password. ssh -q node <<\END_SSH export ORACLE_SID=DB11D_1;ORAENV_ASK=NO;. oraenv >/dev/null 2>&1;sqlplus -s / as sysdba << ENDSQL whenever sqlerror exit 1 alter system set wallet open identified by "Passwo$1"; exit; ENDSQL END_SSH – A Sanghvi Dec 6 '18 at 11:52
  • @ASanghvi I forgot to say that the string inside the here-document additionally needs to be single quoted, as it is shell code. I will add this to the answer. – Kusalananda Dec 6 '18 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.