0

I am trying to store password in a shell variable. Once this step is done, I need to use this password in a curl command.

logmetPassword=$(echo "XXXXXXXXXXXXX==" | openssl enc -base64 -d | openssl enc -des3 -k mysalt -d)
curl -k -XPOST -d '[email protected]&passwd=$logmetPassword&space=myspace&organization=muOrg' https://mywebsite/login

The problem is, it takes $logmetPassword as it is witout substituting the value. I've tried many options:

curl -k -XPOST -d '[email protected]&passwd=${logmetPassword}&  space=myspace&organization=muOrg' https://mywebsite/login
curl -k -XPOST -d '[email protected]&passwd="{$logmetPassword}"&space=myspace&organization=muOrg' https://mywebsite/login
curl -k -XPOST -d '[email protected]&passwd=\"{$logmetPassword}\"&space=myspace&organization=muOrg' https://mywebsite/log

Any suggestions?

0

1 Answer 1

2

If you want $logmetPassword substituted, you must enclose the argument (or that bit of the argument) in double quotes. The shell does not expand any metacharacters inside single quotes.

You could use either of these:

curl -k -XPOST -d "[email protected]&passwd=${logmetPassword}&space=myspace&organization=muOrg" https://mywebsite/login
curl -k -XPOST -d '[email protected]&passwd='"{$logmetPassword}"'&space=myspace&organization=muOrg' https://mywebsite/login

The first encloses everything in double quotes; the second only encloses the password in double quotes. On the whole, I'd probably use the second, but the first is safe for the strings shown.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.