curl - Bash Script: Help find the bug -
i'm trying run script import action via rightscale's api, keeps reporting "bad request 400" second curl operation, , looks url isn't forming correctly. i've tried putting post url in double-quotes, didn't change result.
both accountlist.txt , templatelist.txt have account numbers , template numbers respectively, 1 on each line. debug, i've put 1 account number , template number in each file, respectively.
please me understand what's wrong piece of code. i'm guessing it's trivial, can't understand is:
cat "accountlist.txt" | while read acc ; rm scriptcookie curl -i -h 'x-api-version:1.5' -c scriptcookie -d email="emailid@company.com" -d password="p@sswd" -x post -d account_href="/api/accounts/$acc" https://my.rightscale.com/api/sessions cat "templatelist.txt" | while read temp ; echo $temp curl -i -h 'x_api_version:1.5' -b ./scriptcookie -x post https://my.rightscale.com/api/publications/$temp/import done echo "done account:" $acc done
this output i'm seeing:
<html> <head><title>400 bad request</title></head> <body bgcolor="white"> <center><h1>400 bad request</h1></center> <hr><center>nginx/1.4.2</center> </body> </html>
it turns out version of bash (4.1.5) debian squeeze inserting carriage return '/r' character $temp variable.
i figured out when ran same script on cygwin windows , script ran without issues. @mark setchell suggesting "-xv" flag without i'd have never figured out cause.
this comparison between "echo $temp" line on debian v/s cygwin:
debian (bash-4.1.5):
++ echo $'184605\r'
cygwin (bash-4.1.11):
+ echo 184605
why case? can't answer that, i'm glad figured out it's bash version itself. all!
Comments
Post a Comment