0

I want to write a bash script that should download data from an aspx server. I'm not sure, but I think it is an ASPX server. How can I change the variables in this string? Which is the right way to work with this string in a bash script?

#!/bin/bash

SYMBOL="EURUSD"
YEAR="2017"
WEEK="1"

TYPE="2"
BROKERID="9"
STARDATE="20100301"
ENDDATE="20171231"


wget -c \
    --no-clobber \
    --html-extension \
'http://livetickdata.com/GetData.aspx?type=2&brokerid=9&symbol=EURUSD&startdate=20100301&enddate=20171231&pack=1&key=$' -O $SYMBOL-$YEAR-$WEEK.csv.gz

This doesn't work:

'http://livetickdata.com/GetData.aspx?type=$TYPE&brokerid=$BROKERID&symbol=$SYMBOL&startdate=$STARTDATE&enddate=$ENDDATE&pack=1&key=$' -O $SYMBOL-$YEAR-$WEEK.csv.gz
melpomene
  • 84,125
  • 8
  • 85
  • 148
Aaron
  • 769
  • 1
  • 14
  • 25
  • 1
    Use `"` in place of `'`. – KamilCuk Oct 04 '18 at 11:06
  • 1
    First off, don't use `ALL_UPPERCASE` for your variables. – melpomene Oct 04 '18 at 11:06
  • @StephenC It's a common convention for built-in variables (e.g. `PATH`, `PWD`, `RANDOM`, ...) and system variables (e.g. `HOME`, ...), which makes it easy to avoid accidental name clashes. If you use the same convention for your own variables, it defeats the whole point. – melpomene Oct 04 '18 at 11:10
  • See also [Correct Bash and shell script variable capitalization](https://stackoverflow.com/questions/673055/correct-bash-and-shell-script-variable-capitalization) – tripleee Oct 04 '18 at 11:12

0 Answers0