# wget and bash variables



## zspider (Aug 27, 2010)

Hey

I seem to be having issues getting wget to use bash variables to complete a url that has a date stamp.


```
wget http://weatheroffice.gc.ca/data/radar/temp_image/WKR/WKR_PRECIP_RAIN_$YEAR_$MONTH_$DAYMONTH_$HOUR_00.GIF
```

Yes I do have variables set in the bash shell that are connected to the date command and they do work when I test them individually. Ive tried everything but I cannot get those variables to output just the number that is stored in the variables(including using escape characters). I had one way but it put percent signs in the spaces and kludged the numbers:\ . Any help would be greatly appreciated.


----------



## phoenix (Aug 27, 2010)

Add an "echo" in front of that line, and see what gets spit out.

Run it in "debug" mode using [cmd=]bash -x /path/to/script[/cmd] and see what gets spit out.


----------



## DutchDaemon (Aug 28, 2010)

Additional: your syntax may be confusing. Try specifically separating variables with {}:


```
${YEAR}_${MONTH}_${DAYMONTH}_${HOUR}
```


----------



## zspider (Aug 28, 2010)

DutchDaemon said:
			
		

> Additional: your syntax may be confusing. Try specifically separating variables with {}:
> 
> 
> ```
> ...



That fixed it, now the numbers are being inputted properly. Thanks DutchDaemon and Phoenix.. This can be marked solved now.


----------

