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

[....]

#!/bin/bash

Uname=xyz
Pword=1234

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
http://www.gnu.org/software/bash/manual/bashref.html#Quoting.

Sven


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx
Archive: http://lists.debian.org/87pqecklms.fsf@xxxxxxxxxxxxx



Relevant Pages

  • How to pass variable to wget ?
    ... 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 ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: How to pass variable to wget ?
    ... During the test with "bash -x" I see the variables are not evaluated and they appear as ... $Uname and $Pword. ... the single quotes in your wget command which prevent bash from ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Shell script question
    ... > I am trying to run one of my installation shell script using the ... > 'bash: not found' ... To unsubscribe, ...
    (freebsd-questions)
  • Re: delete ~ directory
    ... >bash will not tries to expand/subsitute it. ... single quotes such as '~' does not get expanded, ... To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list ...
    (Fedora)
  • Re: media slideshow: movies + pictures
    ... since bash does the glob expansion), but at the end of each track, ... VLC goes to a random track rather than to the next one. ... Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)