Re: How to pass variable to wget ?

On 2012-01-22 12:27 +0100, J. Bakshi wrote:

I have a script which submits a form with wget --post-data




wget -O - --save-cookies cookies.txt --post-data \
'username=$Uname&password=$Pword' --keep-session-cookies $URL/$AUTHURL 1&>2


During the test with "bash -x" I see the variables are not evaluated and they appear as
$Uname and $Pword. But if I put an echo for testing at top like

echo $Uname

the value is evaluated correctly.
Am I missing something ?

Yes, the single quotes in your wget command which prevent bash from
expanding the variables. Use double quotes instead, see


To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx