I am trying to use pass double quote and single quote with a variable but I am getting missing quotes error when I run the playbook. Anyone can help with this ?
Final output should be = PASS="'test#123'"
I was able to include double quotes but when I include the single quotes every time it's failing with the missing quotes error.
I'm trying to add this with a loop using the below code. This is working without an issue when I try to add this without a loop.
{ line: "PASS="'{{ passphrase }}'""}
Related
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"
" 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
" is the HTML entity corresponding to the double quotation marks.
See: entity
To convert them check: Short way to escape HTML in Bash? and Bash script to convert from HTML entities to characters
I want to create a function in zshrc for the following command -
node scripts/node_es6.js scripts/small_run_oneoff.js runMiaEventsStatsJob '{"targetDate": "02-01-2018"}'
I want to pass the targetDate as a command line argument. So, I wrote the following function in zshrc -
function mia-events-stats() {
node scripts/node_es6.js scripts/small_run_oneoff.js runMiaEventsStatsJob '{"targetDate": "$1"}'
}
This however does not work. When I execute mia-events-stats 02-01-2018, the targetDate passed to the actual running code is $1.
What am I missing here?
Characters of a string inside single quotes is quoted. Thus, your dollar sign is read as a normal character.
You should replace your single quotes by doubles quotes to let the magic happen, and escape inner double quotes like that:
"{\"targetDate\": \"$1\"}"
If you need your single quotes to be read, simply add them:
"'{\"targetDate\": \"$1\"}'"
Single quotes won't have any effect thanks to doubles quotes.
This is a system Octopus Deploy Variable:
#{Octopus.Action[Deploy To Server].Output.Package.InstallationDirectoryPath}
The text "Deploy to Server" is the name of the step in my project that deploys the Nuget Package to the server. This variable gives the install location of the NugetPackage.
I am wondering if I can make this more generic:
#{Octopus.Action[#{DeploymentStep}].Output.Package.InstallationDirectoryPath}
#{DeploymentStep} is itself a variable with the value of "Deploy to Server"?
I tried this and it not did do the substitution when it tried to run. But I am hoping there is a different syntax for variable in variable substitution.
(I want to do this so I can make this the default value for a Step Template.)
It can be done; but you need to use slightly different syntax!
Variable substitution syntax: http://docs.octopusdeploy.com/display/OD/Variable+Substitution+Syntax
$deploymentStep = "#{DeploymentStep}"
$installationDirectory = $OctopusParameters["Octopus.Action[$deploymentStep].Output.Package.InstallationDirectoryPath"]
Have just had the same issue, but with a few tests I got it working in a 1 liner.
You need to encapsulate the inner variable in brackets with a dollar, and you need to change the double quotes within the variables to single quotes so it doesn't complain about the miss match of quotes. Double quotes on the outside and single quotes in the in.
The example below gets a step name with an octopus variable and also a the machine name it ran on variable to produce the result:
$OctopusParameters["Octopus.Action[$($OctopusParameters['Octopus.Step.Name'])].Output[$($OctopusParameters['Octopus.Machine.Name'])].MyVarFromMachineFromStep"]
I am trying to set the following string as a variable in a bash script and am getting some errors. I assume that it is because I need to use quotations or escape it etc.
VARIABLENAME=$([(A"sometest",SomeOtherText "MoreText"),(A"sometext",SomeOtherText 100),(A"Sometext,SomeOtherText "SomeText")]}))
This doesn't work when I try to set it.
The text inside $(...) will be interpreted as a command to run. I believe you want this instead:
VARIABLENAME='[(A"sometest",SomeOtherText "MoreText"),(A"sometext",SomeOtherText 100),(A"Sometext,SomeOtherText "SomeText")]})'
Use single quotes around your string, as it contains double quotes and does not contain any variables to expand.
One error is near the end:
"Sometext,
There is an unclosed ".
Nested variables have prevented me from trying to use BASH more extensively... consider the following:
export SYS_DIR='/home/${LOGNAME}/sys'
export APP_DIR='${SYS_DIR}/app'
I always end up with
> set
APP_DIR=/home/${LOGNAME}/sys/app
why? lol
and how do I get what I want =/
I'm not trying to resolve ${${var}}, but rather actual strings as shown above
Use double quotes
export APP_DIR="${SYS_DIR}/app"
Single quotes treat everything inside as literal, not evaluated.