I have a script that generates an xml file and then executes a perl script, passing a series of arguments to it. Here's the key code:
CMD="./dnscurl.pl --keyname $KEYNAME -- -X POST -H \"Content-Type: text/xml; charset=UTF-8\" --upload-file /tmp/file.xml https://route53.amazonaws.com/2010-10-01/hostedzone/$HZID/rrset"
echo "Executing..."
echo $CMD
RESULT=`$CMD`
When this executes, the result indicates that something is happening to the embedded arguments after the -H param sent to the dnscurl.pl script:
curl: (6) Couldn't resolve host 'text'
However, I can take the exact command I echo out, and run it from the shell prompt, and the script operates correctly. It seems that when I run it with backtic using RESULT=$CMD
the parameters are not getting passed with the double quotes around the "Content-Type: etc...".
The command I'm running is this one (only the keyname and hostid params were changed)
./dnscurl.pl --keyname mykey -- -X POST -H "Content-Type: text/xml; charset=UTF-8" --upload-file /tmp/file.xml https://route53.amazonaws.com/2010-10-01/hostedzone/ZZZZZZZ/rrset
One thing I'm curious about is the use of the '--' they are passing. I realize that is specific to the dnscurl.pl script handling, but I'm not clear on why that is being passed. Is that due to get around positional argument handling? The script was written to handle 3 different use cases. I don't think it's relevant, but just for completeness, this script is being used to make calls to AWS's route 53 rest api.