I have a .sh script, which, among other things, includes exchange rates from Google as follows:
printf 'Bash: Going to get exchange rates'
echo
wget -qO- "http://www.google.com/finance/converter?a=1&from=usd&to=aud" | sed '/res/!d;s/<[^>]*>//g' > exrates
wget -qO- "http://www.google.com/finance/converter?a=1&from=usd&to=jpy" | sed '/res/!d;s/<[^>]*>//g' >> exrates
wget -qO- "http://www.google.com/finance/converter?a=1&from=usd&to=hkd" | sed '/res/!d;s/<[^>]*>//g' >> exrates
wget -qO- "http://www.google.com/finance/converter?a=1&from=usd&to=nzd" | sed '/res/!d;s/<[^>]*>//g' >> exrates
wget -qO- "http://www.google.com/finance/converter?a=1&from=usd&to=eur" | sed '/res/!d;s/<[^>]*>//g' >> exrates
wget -qO- "http://www.google.com/finance/converter?a=1&from=usd&to=gbp" | sed '/res/!d;s/<[^>]*>//g' >> exrates
mv /home/stan/perl/2014/scripts/exrates /home/stan/perl/2014/exrates/exrates
printf 'Bash: Got exchange rates'
echo
Sometimes the script hangs here. I do not mind not updating these bets every time it works, if it freezes, I would generally skip this step, but how?
What should I include in the if statement to check if wget can receive data quickly or will it last forever? A little more detail on wget will not hurt either.
By the way, I donβt know why the vigette is hanging. The browser opens these pages in order, and the same commands are launched from the command line.
source
share