so I am new to curl and am trying to write a bash script that will I can run that downloads a file. So I start off by authentication then make a POST to request a download. I am given a Foo_ID in which I parse using bash and set to a parameter. I then try to use GET the certain Foo data via a download URL. The issue I am having is that whenever I pass in the parameter I parsed from the POST response I get nothing. Here is an example of what I am doing.
#!/bin/bash
curl -b cookies -c cookies -X POST @login_info -d "https://foo.bar.com/auth"
curl -b cookies -c cookies -X POST @Foo_info -d "https://foo.bar.com/foos" > ./tmp/stuff.t
myFooID=`cat ./tmp/stuff.t |grep -Po '"foo_id:.*?",'|cut -d '"' -f 4`
curl -b cookies -c cookies "http://foo.bar.com/foo-download?id=${myFooID}" > ./myFoos/Foo1.data
I have echo'd myFooID to make sure it is correct and it is. I have also echo'd "https://foo.bar.com/foo-download?id=${myFooID}" and it is properly showing the URL I need. Could anyone help me with this like I said I am new to using curl and a little rusty on using bash commands.
echoit. Doecho "$myFooID"and see if it looks OK. Then doecho -n "$myFooID" | hexdump -Cand see if the hex values show any unexpected characters. If you issue the commands by hand, but substitute the ID literally instead of with a variable, does it work? You don't needcat,grepaccepts filenames as arguments. You should be able to use a variable instead of a temporary file. Use$()instead of backticks. These suggestions won't solve your problem though.