0

I have to pass an argument having double quotes to OpenDJ's dsconfig from a script file. I am taking this argument as input from user.

Issue I am facing is that when I pass this argument to dsconfig procedure, it fails.

Test program:

#!/bin/ksh

bindDN="\"cn=Directory Manager\""

set -x

echo $bindDN

./dsconfig create-backend --port 4444 --hostname haxv-sbatra-1 --bindDN $bindDN -w ndsadmin --backend-name secData --set base-dn:ou=Peopl,o=oamplatform --type local-db --trustAll --set db-num-cleaner-threads:32 --set enabled:true --no-prompt

I tried various things. set -x output for the command shown below. None of it seem to work.

enter image description here

If I hard code the value and run command as

 ./dsconfig create-backend --port 4444 --hostname haxv-sbatra-1 --bindDN "cn=Directory Manager" -w ndsadmin --backend-name secData --set base-dn:ou=Peopl,o=oamplatform --type local-db --trustAll --set db-num-cleaner-threads:32 --set enabled:true --no-prompt

It works fine, it seems somehow single quotes are creating the issue. Is there anyway to avoid single quotes?

codingenious
  • 8,385
  • 12
  • 60
  • 90
  • If `--bindDN "cn=Directory Manager"` works, then why are you attempting to put quotes around it in the variable? That is, when you do `--bindDN "cn=Directory Manager"`, the shell is going to strip off the quotes, and the argument that `./dsconfig` will receive will be `cn=Directory Manager` (no quotes). So if you want to emulate that with a variable, you should do `bindDN="cn=Directory Manager"`, followed by passing `--bindDN "$bindDN"` to `./dsconfig`. – Mike Holt Feb 01 '18 at 18:28
  • Yes, you are right. I am not sure what I was thinking while doing this. :) Please put this as answer. – codingenious Feb 01 '18 at 18:40
  • Btw, [ShellCheck](http://shellcheck.net) automatically detects this issue – that other guy Feb 01 '18 at 19:42

0 Answers0