et en le renomman batterie_level_new.sh ?manuloup a écrit :Aucun. Ils étaient tous déjà en bash. C'est par réflex que j'ai mis /bin/sh dans mon script.
J'ai relancé en supprimant les -e et toujours le même souci. Je débuggerai plus tard. En attendan, mon ancienne version fonctionne.
Si tu veux le debug de ta version, la voici :
Le debug de ma version :Code : Tout sélectionner
root@raspberrypi2:/home/pi/domoticz/scripts/shell# bash -x ./batterie_level.sh.new + DOMOTICZ_SERVER=192.168.1.7:8084 + TABLETTE_IP=192.168.1.62 + BATTERY_TABLETTE_IDX=378 + WALLPLUG_TABLETTE_IDX=380 + cURL=/usr/bin/curl + adb disconnect 192.168.1.62 + sleep 5 ++ adb connect 192.168.1.62 + success='connected to 192.168.1.62:5555' + echo connected to 192.168.1.62:5555 + grep unable + '[' 1 = 0 ']' ++ adb devices + success='List of devices attached 192.168.1.62:5555 offline' + echo List of devices attached 192.168.1.62:5555 offline + grep 192.168.1.62 List of devices attached 192.168.1.62:5555 offline + '[' 0 = 0 ']' + echo List of devices attached 192.168.1.62:5555 offline + grep offline List of devices attached 192.168.1.62:5555 offline + '[' 0 = 0 ']' + voir_les_logs 'Echec de la connection à la tablette 192.168.1.62 : List of devices attached 192.168.1.62:5555 offline' + msg='./batterie_level.sh.new: Echec de la connection à la tablette 192.168.1.62 : List of devices attached 192.168.1.62:5555 offline' + echo ./batterie_level.sh.new: Echec de la connection à la tablette 192.168.1.62 : List of devices attached 192.168.1.62:5555 offline ./batterie_level.sh.new: Echec de la connection à la tablette 192.168.1.62 : List of devices attached 192.168.1.62:5555 offline ++ echo ./batterie_level.sh.new: Echec de la connection à la tablette 192.168.1.62 : List of devices attached 192.168.1.62:5555 offline ++ sed s/%/%25/g + msghtml='./batterie_level.sh.new: Echec de la connection à la tablette 192.168.1.62 : List of devices attached 192.168.1.62:5555 offline' ++ sed 's/ /%20/g' ++ echo ./batterie_level.sh.new: Echec de la connection à la tablette 192.168.1.62 : List of devices attached 192.168.1.62:5555 offline + msghtml=./batterie_level.sh.new:%20Echec%20de%20la%20connection%20à%20la%20tablette%20192.168.1.62%20:%20List%20of%20devices%20attached%20192.168.1.62:5555%20offline + /usr/bin/curl -i -H 'Accept: application/json' 'http://192.168.1.7:8084/json.htm?type=command¶m=addlogmessage&message=./batterie_level.sh.new:%20Echec%20de%20la%20connection%20à%20la%20tablette%20192.168.1.62%20:%20List%20of%20devices%20attached%20192.168.1.62:5555%20offline' HTTP/1.1 200 OK Content-Length: 53 Content-Type: application/json;charset=UTF-8 Cache-Control: no-cache Pragma: no-cache Access-Control-Allow-Origin: * { "status" : "OK", "title" : "AddLogMessage"
Code : Tout sélectionner
root@raspberrypi2:/home/pi/domoticz/scripts/shell# bash -x ./batterie_level.sh + DOMOTICZ_SERVER=192.168.1.7:8084 + TABLETTE_IP=192.168.1.62 + BATTERY_TABLETTE_IDX=378 + WALLPLUG_TABLETTE_IDX=380 + adb disconnect 192.168.1.62 + sleep 5 + adb connect 192.168.1.62 connected to 192.168.1.62:5555 + sleep 5 ++ adb shell dumpsys battery ++ grep level ++ head -n 1 ++ awk '{ print $2 }' + BATTERY_LEVEL=$'97\r' ++ echo $'97\r' ++ tr -d '[:space:]' + BATTERY_LEVEL=97 + echo 'Niveau de la batterie :97' Niveau de la batterie :97 + curl -i -H 'Accept: application/json' 'http://192.168.1.7:8084/json.htm?type=command¶m=udevice&idx=378&nvalue=0&svalue=97' HTTP/1.1 200 OK Content-Length: 53 Content-Type: application/json;charset=UTF-8 Cache-Control: no-cache Pragma: no-cache Access-Control-Allow-Origin: * { "status" : "OK", "title" : "Update Device" } + '[' -z 97 ']' ++ expr 97 '<' 15 + '[' 0 = 1 ']' + echo ' charge batterie superieure a 15 ' charge batterie superieure a 15 ++ expr 97 = 100 + '[' 0 = 1 ']' + echo ' batterie = 97 % ' batterie = 97 %
Bonnes fêtes à tous.