- h) echo "$USAGE"
- exit
- ;;
- t) TIMESPAN=$OPTARG
- ;;
- :) printf "missing argument for -%s\n" "$OPTARG" >&2
- echo "$usage" >&2
- exit 1
- ;;
- \?) printf "illegal option: -%s\n" "$OPTARG" >&2
- echo "$usage" >&2
- exit 1
- ;;
+ h) echo "$USAGE"
+ exit
+ ;;
+ t) TIMESPAN=$OPTARG
+ ;;
+ :) printf "missing argument for -%s\n" "$OPTARG" >&2
+ echo "$usage" >&2
+ exit 1
+ ;;
+ \?) printf "illegal option: -%s\n" "$OPTARG" >&2
+ echo "$usage" >&2
+ exit 1
+ ;;
-if ! ping -c 1 $HOST >/dev/null 2>&1; then
- echo "Host $HOST is unreachable!"
+URL="http://$HOST/export_data.csv?\
+currency=$CURRENCY&\
+data_type=price&\
+exchange=$EXCHANGE&\
+t=l&\
+timespan=$TIMESPAN"
+
+if ! wget -S --spider $URL 2>&1 | grep 'HTTP/1.1 200 OK' >/dev/null; then
+ echo "Can not retrieve data from $HOST!";
set terminal dumb
set datafile separator ","
set xdata time
set timefmt "%Y-%m-%d %H:%M:%S UTC"
set title "EXCHANGE: $EXCHANGE | TIMESPAN: $TIMESPAN\nCURRENCY: $CURRENCY | BTC: $BTC "
set terminal dumb
set datafile separator ","
set xdata time
set timefmt "%Y-%m-%d %H:%M:%S UTC"
set title "EXCHANGE: $EXCHANGE | TIMESPAN: $TIMESPAN\nCURRENCY: $CURRENCY | BTC: $BTC "