Argument not getting parsed correctly using "${args}"

时间:2018-02-01 18:23:01

标签: bash shell ksh

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?

0 个答案:

没有答案