I am running a shell script where I am trying to set the output of the command to a variable but it fails to pass the value of the input variable to the command that gets executed.
#!/bin/bash
request='<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:execute xmlns:ns2="http://common.ravi.com/"><arg0><clientInfoString>data-api</clientInfoString><dsAccessPassPhrase>password</dsAccessPassPhrase><dsAccessUser>user</dsAccessUser><operation>getData</operation><operationArgTypes>com.ravi.SpotMarketKey</operationArgTypes><parameters><object>rO0ABXNyAC5jb20ucmJzLmdibS5yaXNrLmRhdGEubWFya2V0LlNwb3RNYXJrZXRLZXlJbXBsAAAAAAAAAAECAAFMAAxidXNpbmVzc0RhdGV0AB9MY29tL3Jicy9nYm0vcmlzay91dGlsL2RhdGUvRHQ7eHBzcgAoY29tLnJicy5nYm0ucmlzay51dGlsLmRhdGUuRHRVdGlsJER0SW1wbIdazKHBJGu5AgABSQAEZGF0ZXhwAB+THw==</object></parameters><requestId>0_0</requestId><serializationMethod>simple</serializationMethod><serviceName>com.ravi.DataProvider</serviceName></arg0></ns2:execute></soap:Body></soap:Envelope>'
echo $request
res=`curl -X POST -H 'Content-type: text/xml' http://localhost:8080/data-services/services/DataService -d '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:execute xmlns:ns2="http://common.data.risk.gbm.rbs.com/"><arg0><clientInfoString>data-api-6.8.54-SNAPSHOT_LONMW53910</clientInfoString><dsAccessPassPhrase>tim3lord</dsAccessPassPhrase><dsAccessUser>DSUser</dsAccessUser><operation>getFXRateSet</operation><operationArgTypes>com.rbs.gbm.risk.data.market.SpotMarketKey</operationArgTypes><parameters><object>rO0ABXNyAC5jb20ucmJzLmdibS5yaXNrLmRhdGEubWFya2V0LlNwb3RNYXJrZXRLZXlJbXBsAAAAAAAAAAECAAFMAAxidXNpbmVzc0RhdGV0AB9MY29tL3Jicy9nYm0vcmlzay91dGlsL2RhdGUvRHQ7eHBzcgAoY29tLnJicy5nYm0ucmlzay51dGlsLmRhdGUuRHRVdGlsJER0SW1wbIdazKHBJGu5AgABSQAEZGF0ZXhwAB+THw==</object></parameters><requestId>0_0</requestId><serializationMethod>simple</serializationMethod><serviceName>com.rbs.gbm.risk.data.market.FrontOfficeT0DataProvider</serviceName></arg0></ns2:execute></soap:Body></soap:Envelope>'`
echo $res
#fails here
res1=`curl -X POST -H 'Content-type: text/xml' http://localhost:8080/data-services/services/DataService -d '${request}'`
echo $res1
When I run the above script it correctly prints the value of res variable with value of the variable request resolved, but when the command is executed where it says "fails here", in that command the variable request is not resolved.
I have tried many options, calling it as below but no luck.
$(curl -X POST -H 'Content-type: text/xml' http://localhost:8080/data-services/services/DataService -d '${request}')
Any help would be highly appreciated