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

            Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

            밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

            1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴