Impossible d’utiliser un script .sh
Impossible d’utiliser un script .sh
Bonjour.
J'aimerai utiliser un script.sh pour contrôler mes périphériques Android TV depuis Domoticz.
J'ai testé mon script directement en ligne de commande avec Putty est cela fonctionne correctement.
Commande : /Domoticz/var/scripts/ADB.sh action connect 192.168.1.23
Réponse : connected to 192.168.1.23:5555
Mais quand je souhaite l'utiliser avec Domoticz voici la trace dans le log :
Error: Error executing script command (/usr/local/domoticz/var/scripts/ADB.sh). returned: 512
Quelle est l'origine du problème ?
Merci beaucoup pour votre assistance !
J'aimerai utiliser un script.sh pour contrôler mes périphériques Android TV depuis Domoticz.
J'ai testé mon script directement en ligne de commande avec Putty est cela fonctionne correctement.
Commande : /Domoticz/var/scripts/ADB.sh action connect 192.168.1.23
Réponse : connected to 192.168.1.23:5555
Mais quand je souhaite l'utiliser avec Domoticz voici la trace dans le log :
Error: Error executing script command (/usr/local/domoticz/var/scripts/ADB.sh). returned: 512
Quelle est l'origine du problème ?
Merci beaucoup pour votre assistance !
Re: Impossible d’utiliser un script .sh
J'ai oublié un peu de parler de ma config.
Domoticz 4.10717 installé sur un NAS Synology avec Python 3.5.1
Domoticz 4.10717 installé sur un NAS Synology avec Python 3.5.1
-
vil1driver
- Messages : 5661
- Inscription : 30 janv. 2015, 11:07
- Localisation : Rennes (35)
Re: Impossible d’utiliser un script .sh
Salut,
Lors de ton test dans putty, essai de lancer la commande avec sudo
Lors de ton test dans putty, essai de lancer la commande avec sudo
MAJ = VIDER LE CACHE(<-Clicable)
/!\Les mises à jour de Domoticz sont souvent sources de difficultés, ne sautez pas dessus
modules.lua
Un ex domoticzien
/!\Les mises à jour de Domoticz sont souvent sources de difficultés, ne sautez pas dessus
modules.lua
Un ex domoticzien
Re: Impossible d’utiliser un script .sh
le ADB.sh
#!/bin/bash
if [ $1 = "action" ]
then
case $2 in
"connect")
sudo adb connect $3
;;
"disconnect")
sudo adb disconnect $3
;;
"stop")
sudo adb kill-server
;;
"home")
sudo adb shell input keyevent 3
;;
"off")
sudo adb shell input keyevent 5
;;
"power")
adb shell input keyevent 26
;;
"wakeup")
adb shell input keyevent KEYCODE_WAKEUP
;;
"mute")
adb shell service call audio 7 e32 1
;;
"unmute")
adb shell service call audio 7 e32 0
;;
"volume+")
adb shell input keyevent 24
;;
"volume-")
adb shell input keyevent 25
;;
"volume")
adb shell service call audio 3 i32 3 i32 $3
;;
"up")
adb shell input keyevent 19
;;
"down")
adb shell input keyevent 20
;;
"left")
adb shell input keyevent 21
;;
"right")
adb shell input keyevent 22
;;
"back")
adb shell input keyevent KEYCODE_BACK
;;
"click")
adb shell input keyevent 23
;;
"enter")
adb shell input KEYCODE_ENTER
;;
"brightness+")
adb shell input keyevent KEYCODE_BRIGHTNESS_UP
;;
"brightness-")
adb shell input keyevent KEYCODE_BRIGHTNESS_DOWN
;;
"start")
adb shell input keyevent KEYCODE_BUTTON_START
;;
"pause")
adb shell input keyevent KEYCODE_MEDIA_PAUSE
;;
"previous")
adb shell input keyevent KEYCODE_MEDIA_PREVIOUS
;;
"next")
adb shell input keyevent KEYCODE_MEDIA_NEXT
;;
"okgoogle")
adb shell input keyevent KEYCODE_META_LEFT
;;
"cherche")
adb shell input keyevent KEYCODE_SEARCH
;;
"texte")
adb shell input text $3
;;
"youtube")
adb shell monkey -p com.google.android.youtube.tv -c android.intent.category.LAUNCHER 1
;;
"francetv")
adb shell monkey -p fr.francetv.pluzz -c android.intent.category.LAUNCHER 1
;;
"plex")
adb shell monkey -p com.plexapp.android -c android.intent.category.LAUNCHER 1
;;
"spotify")
adb shell monkey -p com.plexapp.android -c android.intent.category.LAUNCHER 1
;;
"vlc")
adb shell monkey -p org.videolan.vlc -c android.intent.category.LAUNCHER 1
;;
"tf1")
adb shell monkey -p fr.tf1.mytf1 -c android.intent.category.LAUNCHER 1
;;
"google")
adb shell monkey -p com.google.android.googlequicksearchbox -c android.intent.category.LAUNCHER 1
;;
"facebook")
adb shell monkey -p com.facebook.katana -c android.intent.category.LAUNCHER 1
;;
"")
adb shell monkey -p com.plexapp.android -c android.intent.category.LAUNCHER 1
;;
esac
fi
if [ $1 = "info" ]
then
case $2 in
"devices")
echo $(adb devices)
;;
"ifconfig")
echo $(adb shell ifconfig)
;;
"appli")
echo $(adb shell 'pm list packages -f' | sed -e 's/.*=//' | sort)
;;
"volume")
result=$(adb shell service call audio 11 i32 3)
echo $((0x${result:31:1}))
;;
esac
fi
#!/bin/bash
if [ $1 = "action" ]
then
case $2 in
"connect")
sudo adb connect $3
;;
"disconnect")
sudo adb disconnect $3
;;
"stop")
sudo adb kill-server
;;
"home")
sudo adb shell input keyevent 3
;;
"off")
sudo adb shell input keyevent 5
;;
"power")
adb shell input keyevent 26
;;
"wakeup")
adb shell input keyevent KEYCODE_WAKEUP
;;
"mute")
adb shell service call audio 7 e32 1
;;
"unmute")
adb shell service call audio 7 e32 0
;;
"volume+")
adb shell input keyevent 24
;;
"volume-")
adb shell input keyevent 25
;;
"volume")
adb shell service call audio 3 i32 3 i32 $3
;;
"up")
adb shell input keyevent 19
;;
"down")
adb shell input keyevent 20
;;
"left")
adb shell input keyevent 21
;;
"right")
adb shell input keyevent 22
;;
"back")
adb shell input keyevent KEYCODE_BACK
;;
"click")
adb shell input keyevent 23
;;
"enter")
adb shell input KEYCODE_ENTER
;;
"brightness+")
adb shell input keyevent KEYCODE_BRIGHTNESS_UP
;;
"brightness-")
adb shell input keyevent KEYCODE_BRIGHTNESS_DOWN
;;
"start")
adb shell input keyevent KEYCODE_BUTTON_START
;;
"pause")
adb shell input keyevent KEYCODE_MEDIA_PAUSE
;;
"previous")
adb shell input keyevent KEYCODE_MEDIA_PREVIOUS
;;
"next")
adb shell input keyevent KEYCODE_MEDIA_NEXT
;;
"okgoogle")
adb shell input keyevent KEYCODE_META_LEFT
;;
"cherche")
adb shell input keyevent KEYCODE_SEARCH
;;
"texte")
adb shell input text $3
;;
"youtube")
adb shell monkey -p com.google.android.youtube.tv -c android.intent.category.LAUNCHER 1
;;
"francetv")
adb shell monkey -p fr.francetv.pluzz -c android.intent.category.LAUNCHER 1
;;
"plex")
adb shell monkey -p com.plexapp.android -c android.intent.category.LAUNCHER 1
;;
"spotify")
adb shell monkey -p com.plexapp.android -c android.intent.category.LAUNCHER 1
;;
"vlc")
adb shell monkey -p org.videolan.vlc -c android.intent.category.LAUNCHER 1
;;
"tf1")
adb shell monkey -p fr.tf1.mytf1 -c android.intent.category.LAUNCHER 1
;;
"google")
adb shell monkey -p com.google.android.googlequicksearchbox -c android.intent.category.LAUNCHER 1
;;
"facebook")
adb shell monkey -p com.facebook.katana -c android.intent.category.LAUNCHER 1
;;
"")
adb shell monkey -p com.plexapp.android -c android.intent.category.LAUNCHER 1
;;
esac
fi
if [ $1 = "info" ]
then
case $2 in
"devices")
echo $(adb devices)
;;
"ifconfig")
echo $(adb shell ifconfig)
;;
"appli")
echo $(adb shell 'pm list packages -f' | sed -e 's/.*=//' | sort)
;;
"volume")
result=$(adb shell service call audio 11 i32 3)
echo $((0x${result:31:1}))
;;
esac
fi
Re: Impossible d’utiliser un script .sh
J'ai essayé, cela fonctionne aussi.vil1driver a écrit : 15 août 2019, 12:42 Salut,
Lors de ton test dans putty, essai de lancer la commande avec sudo
Je pense que le problème viens de l'accès au ssh de Domoticz ...
Quel utilisateur est utilisé ? Comment le paramétrer ?
Sur le Synology, la connexion au root est réalisable uniquement avec une clef ssh.
Je ne suis pas encore assez connaisseur en la matière ...
Merci.
Re: Impossible d’utiliser un script .sh
Salut,
Tu peux essayer un ssh-keygen, et un ssh-copy-id pour échanger une clé, comme ceci plus d'authentification.
Tu peux essayer un ssh-keygen, et un ssh-copy-id pour échanger une clé, comme ceci plus d'authentification.
Re: Impossible d’utiliser un script .sh
Hello et merci.
J'ai bien fait la démarche.
Maintenant, comment dire à Domoticz d'utiliser l'utilisateur sans d'authentification ?
J'ai bien fait la démarche.
Maintenant, comment dire à Domoticz d'utiliser l'utilisateur sans d'authentification ?
Re: Impossible d’utiliser un script .sh
Dans les deux cas, le chemin d'accès n'est pas le même :Holborn a écrit : 15 août 2019, 12:05
Commande : /Domoticz/var/scripts/ADB.sh action connect 192.168.1.23
Réponse : connected to 192.168.1.23:5555
Mais quand je souhaite l'utiliser avec Domoticz voici la trace dans le log :
Error: Error executing script command (/usr/local/domoticz/var/scripts/ADB.sh). returned: 512
1er cas OK : /Domoticz/var/scripts/ADB.sh
2èm cas KO : /usr/local/domoticz/var/scripts/ADB.sh
Re: Impossible d’utiliser un script .sh
Hello est encore merci.
Maintenant je souhaite intégrer le script.sh dans un script.lua
J'utilise donc les fonctions suivantes :
os.execute('bash /Domoticz/var/scripts/ADB.sh action connect 192.168.1.23')
os.execute('bash /Domoticz/var/scripts/ADB.sh info devices')
J'ai placé des echo pour suivre dans un fichier log.
exemple : echo $1 $2 $3 >> /tmp/debug_log
Grâce à cela, je constate que les données d'entrée sont bien reçues par le script
action connect 192.168.1.23
Mais malheureusement, les fonctions sudo adb et shell ne fonctionnent pas et ne me renvoient rien.
echo var=$(commande) >> /tmp/debug_log est vide
echo 1 $(adb devices) >> /tmp/debug_log est vide également.
Je rappel que le script fonctionne parfaitement en commande direct :
root@ServeurMaison:~# /Domoticz/var/scripts/ADB.sh info devices
List of devices attached
Merci par avance pour toutes aides !
Maintenant je souhaite intégrer le script.sh dans un script.lua
J'utilise donc les fonctions suivantes :
os.execute('bash /Domoticz/var/scripts/ADB.sh action connect 192.168.1.23')
os.execute('bash /Domoticz/var/scripts/ADB.sh info devices')
J'ai placé des echo pour suivre dans un fichier log.
exemple : echo $1 $2 $3 >> /tmp/debug_log
Grâce à cela, je constate que les données d'entrée sont bien reçues par le script
action connect 192.168.1.23
Mais malheureusement, les fonctions sudo adb et shell ne fonctionnent pas et ne me renvoient rien.
echo var=$(commande) >> /tmp/debug_log est vide
echo 1 $(adb devices) >> /tmp/debug_log est vide également.
Je rappel que le script fonctionne parfaitement en commande direct :
root@ServeurMaison:~# /Domoticz/var/scripts/ADB.sh info devices
List of devices attached
Merci par avance pour toutes aides !
Re: Impossible d’utiliser un script .sh
Hello,
Personne n'a une idée ?
Cela fonctionne en console mais pas en appel dans le bash ...
Un problème d'utilisateur ? de droits ? Je ne comprend vraiment pas d'où viens le problème !
Merci.
Personne n'a une idée ?
Cela fonctionne en console mais pas en appel dans le bash ...
Un problème d'utilisateur ? de droits ? Je ne comprend vraiment pas d'où viens le problème !
Merci.