Problem with curl and scripting for OpenStack [duplicate]Are shell scripts sensitive to encoding and line endings?Get the source directory of a Bash script from within the script itselfHow do I prompt for Yes/No/Cancel input in a Linux shell script?How to iterate over arguments in a Bash scriptHow to check if a program exists from a Bash script?Pipe to/from the clipboard in Bash scriptYYYY-MM-DD format date in shell scriptHow to declare and use boolean variables in shell script?How to do a logical OR operation in shell scriptingCheck existence of input argument in a Bash shell scriptWhat does set -e mean in a bash script?

Did Wernher von Braun really have a "Saturn V painted as the V2"?

Show two plots together: a two dimensional curve tangent to the maxima of a three dimensional plot

How could Tony Stark wield the Infinity Nano Gauntlet - at all?

What if a restaurant suddenly cannot accept credit cards, and the customer has no cash?

My new Acer Aspire 7 doesn't have a Legacy Boot option, what can I do to get it?

Why do aircraft leave cruising altitude long before landing just to circle?

Virtual destructor moves object out of rodata section

Adding things to bunches of things vs multiplication

Is there a utility / method to organize trad gear so that each piece is immediately accessible?

Metal that glows when near pieces of itself

Output with the same length always

Why do balloons get cold when they deflate?

The Lucky House

Installing certbot - error - "nothing provides pyparsing"

Starships without computers?

Check disk usage of files returned with spaces

What happens to thrust and drag in a straight and level flight?

Are there reliable, formulaic ways to form chords on the guitar?

Have made several mistakes during the course of my PhD. Can't help but feel resentment. Can I get some advice about how to move forward?

Is there a commercial liquid with refractive index greater than n=2?

Meaning and structure of headline "Hair it is: A List of ..."

Replacing old plug-in 220V range with new hardwire 3-wire electric cooktop: remove outlet or add a plug?

Testing control surfaces pre flight; what feedback does pilot recieve?

Why was ramjet fuel used as hydraulic fluid during Saturn V checkout?



Problem with curl and scripting for OpenStack [duplicate]


Are shell scripts sensitive to encoding and line endings?Get the source directory of a Bash script from within the script itselfHow do I prompt for Yes/No/Cancel input in a Linux shell script?How to iterate over arguments in a Bash scriptHow to check if a program exists from a Bash script?Pipe to/from the clipboard in Bash scriptYYYY-MM-DD format date in shell scriptHow to declare and use boolean variables in shell script?How to do a logical OR operation in shell scriptingCheck existence of input argument in a Bash shell scriptWhat does set -e mean in a bash script?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1
















This question already has an answer here:



  • Are shell scripts sensitive to encoding and line endings?

    5 answers



I'm presently doing a shell script to create some networks / VMs on Openstack. Here, I'm first getting the token and then I'm trying to list all images. However, there seems to be some kind of problem with an environment variable



echo "GETTING TOKEN"
res=$( curl -sD - -o /dev/null
-H "Content-Type: application/json"
-d '
...
}'
http://$1/identity/v3/auth/tokens)

token=$(echo "$res" | awk '/X-Subject-Token: /print $NF')

export OS_TOKEN="$token"

echo $OS_TOKEN

echo "X-Auth-Token: $OS_TOKEN"

curl -s
--header "X-Auth-Token: $OS_TOKEN"
http://$1/image/v2/images


this is the output that i'm getting :



devstack@MFZhani:~$ ./script.sh localhost
GETTING TOKEN
THE TOKEN
X-Auth-Token: THE SAME TOKEN
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.27 (Ubuntu) Server at 127.0.0.1 Port 80</address>
</body></html>


The thing is, when I hardcode the token, it works. Also, I know it's not caused by a bad character in the variable because I'm doing other commands with the exact same token for creating networks and it works just fine (the difference here is that i'm doing a GET instead of a POST).










share|improve this question
















marked as duplicate by oguz ismail, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 27 at 14:58


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • try with set -x

    – Kamil Cuk
    Mar 27 at 14:00











  • like this : curl -s set -x --header "X-Auth-Token: $OS_TOKEN" http://$1/image/v2/images ??

    – etiennnr
    Mar 27 at 14:04






  • 1





    add set -x to the beginning of the script, on the first line. Run. Observe the output. The lines starting + are commands that are executing. Search google on how to debug bash scripts.

    – Kamil Cuk
    Mar 27 at 14:06


















-1
















This question already has an answer here:



  • Are shell scripts sensitive to encoding and line endings?

    5 answers



I'm presently doing a shell script to create some networks / VMs on Openstack. Here, I'm first getting the token and then I'm trying to list all images. However, there seems to be some kind of problem with an environment variable



echo "GETTING TOKEN"
res=$( curl -sD - -o /dev/null
-H "Content-Type: application/json"
-d '
...
}'
http://$1/identity/v3/auth/tokens)

token=$(echo "$res" | awk '/X-Subject-Token: /print $NF')

export OS_TOKEN="$token"

echo $OS_TOKEN

echo "X-Auth-Token: $OS_TOKEN"

curl -s
--header "X-Auth-Token: $OS_TOKEN"
http://$1/image/v2/images


this is the output that i'm getting :



devstack@MFZhani:~$ ./script.sh localhost
GETTING TOKEN
THE TOKEN
X-Auth-Token: THE SAME TOKEN
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.27 (Ubuntu) Server at 127.0.0.1 Port 80</address>
</body></html>


The thing is, when I hardcode the token, it works. Also, I know it's not caused by a bad character in the variable because I'm doing other commands with the exact same token for creating networks and it works just fine (the difference here is that i'm doing a GET instead of a POST).










share|improve this question
















marked as duplicate by oguz ismail, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 27 at 14:58


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • try with set -x

    – Kamil Cuk
    Mar 27 at 14:00











  • like this : curl -s set -x --header "X-Auth-Token: $OS_TOKEN" http://$1/image/v2/images ??

    – etiennnr
    Mar 27 at 14:04






  • 1





    add set -x to the beginning of the script, on the first line. Run. Observe the output. The lines starting + are commands that are executing. Search google on how to debug bash scripts.

    – Kamil Cuk
    Mar 27 at 14:06














-1












-1








-1









This question already has an answer here:



  • Are shell scripts sensitive to encoding and line endings?

    5 answers



I'm presently doing a shell script to create some networks / VMs on Openstack. Here, I'm first getting the token and then I'm trying to list all images. However, there seems to be some kind of problem with an environment variable



echo "GETTING TOKEN"
res=$( curl -sD - -o /dev/null
-H "Content-Type: application/json"
-d '
...
}'
http://$1/identity/v3/auth/tokens)

token=$(echo "$res" | awk '/X-Subject-Token: /print $NF')

export OS_TOKEN="$token"

echo $OS_TOKEN

echo "X-Auth-Token: $OS_TOKEN"

curl -s
--header "X-Auth-Token: $OS_TOKEN"
http://$1/image/v2/images


this is the output that i'm getting :



devstack@MFZhani:~$ ./script.sh localhost
GETTING TOKEN
THE TOKEN
X-Auth-Token: THE SAME TOKEN
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.27 (Ubuntu) Server at 127.0.0.1 Port 80</address>
</body></html>


The thing is, when I hardcode the token, it works. Also, I know it's not caused by a bad character in the variable because I'm doing other commands with the exact same token for creating networks and it works just fine (the difference here is that i'm doing a GET instead of a POST).










share|improve this question

















This question already has an answer here:



  • Are shell scripts sensitive to encoding and line endings?

    5 answers



I'm presently doing a shell script to create some networks / VMs on Openstack. Here, I'm first getting the token and then I'm trying to list all images. However, there seems to be some kind of problem with an environment variable



echo "GETTING TOKEN"
res=$( curl -sD - -o /dev/null
-H "Content-Type: application/json"
-d '
...
}'
http://$1/identity/v3/auth/tokens)

token=$(echo "$res" | awk '/X-Subject-Token: /print $NF')

export OS_TOKEN="$token"

echo $OS_TOKEN

echo "X-Auth-Token: $OS_TOKEN"

curl -s
--header "X-Auth-Token: $OS_TOKEN"
http://$1/image/v2/images


this is the output that i'm getting :



devstack@MFZhani:~$ ./script.sh localhost
GETTING TOKEN
THE TOKEN
X-Auth-Token: THE SAME TOKEN
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.27 (Ubuntu) Server at 127.0.0.1 Port 80</address>
</body></html>


The thing is, when I hardcode the token, it works. Also, I know it's not caused by a bad character in the variable because I'm doing other commands with the exact same token for creating networks and it works just fine (the difference here is that i'm doing a GET instead of a POST).





This question already has an answer here:



  • Are shell scripts sensitive to encoding and line endings?

    5 answers







bash sh openstack






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 14:24









Aserre

3,4893 gold badges22 silver badges45 bronze badges




3,4893 gold badges22 silver badges45 bronze badges










asked Mar 27 at 13:58









etiennnretiennnr

156 bronze badges




156 bronze badges





marked as duplicate by oguz ismail, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 27 at 14:58


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











marked as duplicate by oguz ismail, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 27 at 14:58


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by oguz ismail, tripleee bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 27 at 14:58


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • try with set -x

    – Kamil Cuk
    Mar 27 at 14:00











  • like this : curl -s set -x --header "X-Auth-Token: $OS_TOKEN" http://$1/image/v2/images ??

    – etiennnr
    Mar 27 at 14:04






  • 1





    add set -x to the beginning of the script, on the first line. Run. Observe the output. The lines starting + are commands that are executing. Search google on how to debug bash scripts.

    – Kamil Cuk
    Mar 27 at 14:06


















  • try with set -x

    – Kamil Cuk
    Mar 27 at 14:00











  • like this : curl -s set -x --header "X-Auth-Token: $OS_TOKEN" http://$1/image/v2/images ??

    – etiennnr
    Mar 27 at 14:04






  • 1





    add set -x to the beginning of the script, on the first line. Run. Observe the output. The lines starting + are commands that are executing. Search google on how to debug bash scripts.

    – Kamil Cuk
    Mar 27 at 14:06

















try with set -x

– Kamil Cuk
Mar 27 at 14:00





try with set -x

– Kamil Cuk
Mar 27 at 14:00













like this : curl -s set -x --header "X-Auth-Token: $OS_TOKEN" http://$1/image/v2/images ??

– etiennnr
Mar 27 at 14:04





like this : curl -s set -x --header "X-Auth-Token: $OS_TOKEN" http://$1/image/v2/images ??

– etiennnr
Mar 27 at 14:04




1




1





add set -x to the beginning of the script, on the first line. Run. Observe the output. The lines starting + are commands that are executing. Search google on how to debug bash scripts.

– Kamil Cuk
Mar 27 at 14:06






add set -x to the beginning of the script, on the first line. Run. Observe the output. The lines starting + are commands that are executing. Search google on how to debug bash scripts.

– Kamil Cuk
Mar 27 at 14:06













1 Answer
1






active

oldest

votes


















0














Found it with the set -x suggested by Kamil Cuk. There was a r that I was not able to see otherwise. Deleted it and it worked. Thanks.






share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Found it with the set -x suggested by Kamil Cuk. There was a r that I was not able to see otherwise. Deleted it and it worked. Thanks.






    share|improve this answer





























      0














      Found it with the set -x suggested by Kamil Cuk. There was a r that I was not able to see otherwise. Deleted it and it worked. Thanks.






      share|improve this answer



























        0












        0








        0







        Found it with the set -x suggested by Kamil Cuk. There was a r that I was not able to see otherwise. Deleted it and it worked. Thanks.






        share|improve this answer













        Found it with the set -x suggested by Kamil Cuk. There was a r that I was not able to see otherwise. Deleted it and it worked. Thanks.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 27 at 14:37









        etiennnretiennnr

        156 bronze badges




        156 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.





            Popular posts from this blog

            How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

            Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?