Issue
In one of my variables I store result (string) from aws cli command.
When echoing the value it is displayed in " "
but injecting it as a parameter shows that extra characters ("
) are added at the beginning and end of the string.
How to eliminate these? What do they represent?
Code and error log:
dms_arn=$(aws dms describe-replication-tasks --filter Name=replication-task-id,Values="$dms_name" `--query=ReplicationTasks[0].ReplicationTaskArn --region us-east-1)`
echo Stopping Task "$dms_arn"
build 02-Nov-2021 18:52:01 Stopping Task "arn:aws:dms:us-east-1:account:task:XYZ"
error 02-Nov-2021 18:52:02
error 02-Nov-2021 18:52:02 An error occurred (InvalidParameterValueException) when calling the StopReplicationTask operation: Invalid task ARN: "arn:aws:dms:us-east-1:account:task:XYZ"
Solution
"
is the html code for double quote ("
). The double quotes are being converted to html code.
Try using the —output text
option with your aws
command (so you don’t get quotes). See the documentation about output format: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-output-format.html
If necessary, you can remove wrapping double quotes using shell parameter expansion:
dms_arn=${dms_arn%\"}
dms_arn=${dms_arn#\"}
echo "$dms_arn"
# quotes are gone
Answered By - dan Answer Checked By - Cary Denson (WPSolving Admin)