bashshellunixsiebel

Parameter variable not getting appended


i have a UNIX shell script where i am passing values in form of parameters.Everything seems working good , but not for one parameter , but i can see it printed with echo command.

Script-:

#!/bin/bash

admPath=$1
admdatatype=$2
admeaimethod=$3
admprefix=$4
gatewayname=$5
enterpriseName=$6
userId=$7
password=$8
admFilter=$9

echo "$admPath"
echo "$admdatatype"
echo "$admeaimethod"
echo "$admprefix"
echo "$gatewayname"
echo "$enterpriseName"
echo "$userId"
echo "$password"
echo "$admFilter"


srvrmgr -g "$gatewayname" -e "$enterpriseName" -s gepfdevss -u "$userId" -p "$password" -c "run task for comp ADMBatchProc with admpath="$admPath", admdatatype="$admdatatype", admfilter="'$admFilter'", admeaimethod=$admeaimethod, admprefix="$admprefix"" -b >> exportLOVStatus.out

As you can see i have one parameter called admFilter whose value i want to pass as '[List Of Values Parent (UDA).Value]=\"XRX_TEST\"' .

When i execute above script i can see echo result as below -:

execution -:

./exportLOV.sh "/global/u70/globepfdev/ADM" "LOV" "Upsert" "export_ADM" "gateway" "enterpriseserver" "user" "password" \''[List Of Values Parent (UDA).Value]=\"XRX_TEST\"'\'

Echo result -:

/global/u70/globepfdev/ADM
LOV
Upsert
export_ADM
gateway
enterprise
user
password
'[List Of Values Parent (UDA).Value]=\"XRX_TEST\"'

But as the command is executed for Server Manager after successfull connection . This admFilter parameter is not reading value . This is the output for run task command -:

run task for comp ADMBatchProc with admpath=/global/u70/globepfdev/ADM, admdatatype=LOV, admfilter=$admFilter, admeaimethod=Upsert, admprefix=export_ADM

You can see every other parameter have a value associated with it apart from admFilter . I am stuck because of this can anyone help me out . How can i pass value properly?? Thanks


Solution

  • Single quotes prevent variables from being expanded. You should be putting the single quotes inside the double-quoted string, so they'll be sent literally to the srvrmgr command, not outside it.

    There's also no need to end the double quotes around each variable in the -c argument.

    srvrmgr -g "$gatewayname" -e "$enterpriseName" -s gepfdevss -u "$userId" -p "$password" -c "run task for comp ADMBatchProc with admpath=$admPath, admdatatype=$admdatatype, admfilter='$admFilter', admeaimethod=$admeaimethod, admprefix=$admprefix" -b >> exportLOVStatus.out
    

    See Difference between single and double quotes in Bash