Benedikt Benedikt - 1 year ago 74
Bash Question

Why does this shell script not take the variables?

I'm trying to wget a bunch of excel tables on a website. I'm trying to write a shell script to do this for me:

eventid="someid" \
url=""$eventid"/sessions?format=xlsx" \
wget --load-cookies cookies.txt -p $url

It does not seem to take the variables in wget. It says that the urls is missing for wget.

Answer Source

Because of the escapes, this is just one line in the form of:

var1=value var2=value2 application ...

Which just sets the environment variables for the launched the application (but not for the shell). As you've never set the value for $url in the current shell, it's going to be empty.

Remove the \s.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download