Hi, sorry this is a newbie questions I fear:
I am trying to update one of my bash scripts to work with Firefox3's sqlite cookie format.
I can extract the cookie values but am trying to pass them as a string variable to the -b parameter in curl, rather than as a reference to a netscape format cookie.txt file.
The curl MAN page explains that this is possible and it works if I pass the hardcoded string cURL -b"pass=xyz;userID=123", but when I pass the same data as a variable it breaks. I've tried all manner of escaping, quoting, echoing the variable and using brackets and backticks but am really stuck.
I'm building the string by querying sqlite for the individual values:
Code:
ffcf=[path to cookies.sqlite]
thepass=`sqlite3 "$ffcf" "select value from moz_cookies where host='[host string]' and name='pass'"`
theUID=`sqlite3 "$ffcf" "select value from moz_cookies where host='[host string]' and name='uid'"`
then concatenating them into a variable
Code:
inputcookiefn="pass="$thepass"';'UID="$theUID"
echo "Input Cookie String:" "$inputcookiefn"
which looks right when I echo it back
so my curl command looks like:
Code:
curl -s -S -b "$inputcookies" -c newcookies.txt -A 'Mozilla/4.0' [website URL here] > testresults.htm
The cURL command completes, but the site doesn't accept the cookies when passed as a variable, although it accepts the hardcoded string as shown above, which _appears_ to be identical.
I am trying to avoid the need to generate a cookies.txt file from the sqlite queries and just build a string value for the -b parameter.
Any help or pointers much appreciated.