user1592380
user1592380

Reputation: 36247

Bash variable not expanding

I'm trying to log into a website using the auth cookies , using the techniques described in I'm reading through https://www.apharmony.com/software-sagacity/2014/10/using-wget-with-cookies/ .

I'm trying to turn my task into a bash script which I will use with git-bash. So far I have the tested wget with the cookies directly at the command line and the login works using:

wget --header "cookie: _ga=GA1.2.3865356.1523153047; ......" www.mysite.com

However in the Bash script , I have:

COOKIES="cookie:_ga=GA1.2.3865356.1523153047; ...."
wget --header $COOKIES www.mysite.com

This does not work. What am I doing wrong in the bash script?

Upvotes: 0

Views: 2805

Answers (1)

dr_agon
dr_agon

Reputation: 333

The value you assign to the COOKIES variable is without the quotes. You must either include the quotes within the variable, or quote the contents afterwards. The easiest solution seems to be:

COOKIES="'cookie:_ga=GA1.2.3865356.1523153047; ....'"
wget --header $COOKIES www.mysite.com

Upvotes: 1

Related Questions