I have a problem when using curl on my linux script:
#!/bin/bash userName="user"; passWord="password"; tenantName="tenant"; commande="curl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -H \"Postman-Token: 111131da-8254-21b3-1b95-9c12954152c9\" -d '{\"auth\":{\"tenantName\":\"$tenantName\",\"passwordCredentials\": {\"username\":\"$userName\",\"password\":\"$passWord\"}}}' \"http://controller:5000/v2.0/tokens\""
When the output of the variable commande is copy pasted into the shell it works, but when i use :
res= $(eval $commande) #or res=`$commande`
Neither one of those commands works, and this is the output error i usually get:
line 11: {"access":: command not found
PS: If i do
echo $commande
And then i copy past the result on the shell it works,If anyone can help me that would be great !
commande
in one place, andcomande
in another. Also{"access":
looks like part of a JSON snippet, but your first code snippet doesn't have that anywhere.res=`$commande`
instruction? That attempt is less wrong than the other one.