I have made a very simple weather widget. It should work but it doesn’t. For some reason the variables Code2, Code3 etc. don’t get initialized before they are needed. The problem is timing - the commands themselves should work. So, is there ANY way to wait until a shell command has actually finished before continuing? I really need to know when the “wget” has actually gathered the needed data. Now only the 1st icon is actually displayed, the rest are not because the corresponding CodeN variables are not initialized. That is not the only problem. For some reason, if I comment out the wget line, I still get only 4 images shown correctly. The 5th image still fails because apparently the resizing can’t finish fast enough. Basically ChangeIcon 5 line is executed before the resizing is finished.
What is the proper way to do these kind of things?
Init
Begin
Set $Url = {"} {http://xml.weather.yahoo.com/forecastrss?p=USCA1116&u=} {"$TempUnits"} {"}
Do {exec wget -q -O "$WeatherFile" } $Url
Set $Code1 = (GetOutput {Test=`cat "$WeatherFile" | grep code | tail -n 5 | head -n 1 | sed -e 's/<yweather:forecast //' -e 's/\/>//'` && eval $Test && echo $code} 1 -1)
Do {exec $[FVWM_USERDIR]/scripts/resize/resize $[FVWM_USERDIR]/images/weather/} $Code1 {.png $[FVWM_USERDIR]/images/weather/icon1.png 50 50}
Set $Code2 = (GetOutput {Test=`cat "$WeatherFile" | grep code | tail -n 4 | head -n 1 | sed -e 's/<yweather:forecast //' -e 's/\/>//'` && eval $Test && echo $code} 1 -1)
Do {exec $[FVWM_USERDIR]/scripts/resize/resize $[FVWM_USERDIR]/images/weather/} $Code2 {.png $[FVWM_USERDIR]/images/weather/icon2.png 50 50}
Set $Code3 = (GetOutput {Test=`cat "$WeatherFile" | grep code | tail -n 3 | head -n 1 | sed -e 's/<yweather:forecast //' -e 's/\/>//'` && eval $Test && echo $code} 1 -1)
Do {exec $[FVWM_USERDIR]/scripts/resize/resize $[FVWM_USERDIR]/images/weather/} $Code3 {.png $[FVWM_USERDIR]/images/weather/icon3.png 50 50}
Set $Code4 = (GetOutput {Test=`cat "$WeatherFile" | grep code | tail -n 2 | head -n 1 | sed -e 's/<yweather:forecast //' -e 's/\/>//'` && eval $Test && echo $code} 1 -1)
Do {exec $[FVWM_USERDIR]/scripts/resize/resize $[FVWM_USERDIR]/images/weather/} $Code4 {.png $[FVWM_USERDIR]/images/weather/icon4.png 50 50}
Set $Code5 = (GetOutput {Test=`cat "$WeatherFile" | grep code | tail -n 1 | sed -e 's/<yweather:forecast //' -e 's/\/>//'` && eval $Test && echo $code} 1 -1)
Do {exec $[FVWM_USERDIR]/scripts/resize/resize $[FVWM_USERDIR]/images/weather/} $Code5 {.png $[FVWM_USERDIR]/images/weather/icon5.png 50 50}
Set $Icon1 = {weather/icon1.png}
Set $Icon2 = {weather/icon2.png}
Set $Icon3 = {weather/icon3.png}
Set $Icon4 = {weather/icon4.png}
Set $Icon5 = {weather/icon5.png}
ChangeIcon 1 $Icon1
ChangeIcon 2 $Icon2
ChangeIcon 3 $Icon3
ChangeIcon 4 $Icon4
ChangeIcon 5 $Icon5
End
PS. Long lines got wrapped…