Re: [resolut] Conversion dans un script . sh
Publié : 26 oct. 2015, 11:45
J'ai un vrai probleme :
Voici mon script :
Lorsque j'execute mon script depuis une fenetre du terminal pas de probleme il met bien ma station meteo a jour.
Si je le lance depuis un crontab, des infos sont bien envoyé mais tout a 0 vous auriez une idee ?
Voici mon script :
Code : Tout sélectionner
#!/bin/bash
# GET sensor Value
#Rainain
#actual
rainin=$(curl -s "http://192.168.0.21:8080/json.htm?type=devices&rid=9"| jq -r .result[].RainRate)
echo "Pluie maintenant : ${rainin}mm"
#daily
dailyrainin=$(curl -s "http://192.168.0.21:8080/json.htm?type=devices&rid=9"| jq -r .result[].Rain)
echo "Pluie sur la journée : ${dailyrainin}mm/Jour"
#External Temp Hum & dewpoint
tempc=$(curl -s "http://192.168.0.21:8080/json.htm?type=devices&rid=150"| jq -r .result[].Temp)
echo "Temperature exterieur : ${tempc} c"
#need some math to converte on C to F thx vil1driver
tempf=$(echo "scale=2;((9/5) * $tempc) + 32" | bc)
echo "temp en °f : ${tempf} f"
humidity=$(curl -s "http://192.168.0.21:8080/json.htm?type=devices&rid=150"| jq -r .result[].Humidity)
echo "Humidité exterieur : ${humidity}%"
dewptc=$(curl -s "http://192.168.0.21:8080/json.htm?type=devices&rid=150"| jq -r .result[].DewPoint)
echo "Point de rosée : ${dewptc} c"
#need some math to converte on C to F thx vil1driver
dewptf=$(echo "scale=2;((9/5) * $dewptc) + 32" | bc)
echo "Point de rosée : ${dewptf} f"
#Baro
barohp=$(curl -s "http://192.168.0.21:8080/json.htm?type=devices&rid=8"| jq -r .result[].Barometer)
echo "Pression : ${barohp} HPA"
#need some math to converte on HPA to Inch
baroin=`echo "0.0295299830714*$barohp" | bc`
echo "Pression en Inch : ${baroin} in"
#Wind direction :
winddir=$(curl -s "http://192.168.0.21:8080/json.htm?type=devices&rid=267"| jq -r .result[].Direction)
echo "direction du vent : ${winddir}"
#WUind gust :
wgskmh=$(curl -s "http://192.168.0.21:8080/json.htm?type=devices&rid=267"| jq -r .result[].Gust| tr -d '"')
echo "vitesse des rafales : ${wgskmh} km/h"
#need some math to translat on mph
wgsmph=`echo "0.621371192*$wgskmh" | bc`
echo "Viteese des rafales : ${wgsmph} mph"
#WUind speed :
wspkmh=$(curl -s "http://192.168.0.21:8080/json.htm?type=devices&rid=267"| jq -r .result[].Speed| tr -d '"')
echo "vitesse du vent : ${wspkmh} km/h"
#need some math to translat on mph
wsmph=`echo "0.621371192*$wspkmh" | bc`
echo "vitesse du vent : ${wsmph} mph"
#formating info for Update WU and send it
curl "http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=******&PASSWORD=****&dateutc=now&winddir=${winddir}&windspeedmph=${wsmph}&windgustmph=${wgsmph}&tempf=${tempf}&rainin=${rainin}&dailyrainin=${dailyrainin}&baromin=${baroin}&dewptf=${dewptf}&humidity=${humidity}&softwaretype=vws%20versionxx&action=updateraw"
Si je le lance depuis un crontab, des infos sont bien envoyé mais tout a 0 vous auriez une idee ?