Pbl exécution script bash

Hello, je souhaite exécuter un script bash à partir de jeedom pour redémarrer ma box Internet.

Ma box reboot bien lorsque j’exécute le script en CLI mais lorsque je demande à Jeedom de l’exécuter, ma box ne redémarre pas.

J’ai ajouté une ligne de test en début du code pour vérifier que le script soit bien exécuté et c’est le cas.

echo "test" >/tmp/test.txt

résultat:
image

J’ai également suivi ce post pour tester l’exécution du script en tant que www-data et ma box redémarre bien.

Un truc me dépasse là mais je tourne en rond depuis 2h :frowning:
Voyez-vous qqchose que j’aurai zappé ?

image


# TEST POUR VERIFIER QUE LE SCRIPT S'EXECUTE
echo "test" >/tmp/test.txt

# This script reboot the AVM FritzBox router
BOX="192.168.1.1"
echo "looking for fritzbox"

if ! ping -c1 $BOX &>/dev/null; then
 echo "couldn't find fritzbox"
 exit
fi

echo "fritzbox found"

echo "retrieving session id $SID "
SID=$(curl -s -I "http://$BOX/logincheck.lua" | grep -Fi Location | awk -F'[=]' '{print $2}') 
sleep 1
echo "session id $SID"

echo "requesting reboot"
SID=$(curl -s -i -H "Content-Type: application/x-www-form-urlencoded" -H "Origin: http://$BOX" -H "Referer: http://$BOX/system/reboot.lua\?sid\=$SID" --data "reboot=&sid=$SID" -L http://$BOX/system/reboot.lua | grep -Fi Location | awk -F'[=]' '{print $2}') 

echo "new session id $SID"
sleep 1

echo "requesting status"
curl http://$BOX/reboot.lua?ajax=1&sid=$REBOOT_SID
sleep 1

echo "waiting for fritzbox to go down"
while ping -c1 www.google.com &>/dev/null; do : sleep 1; done
echo "FRITZ!Box down"
sleep 1

echo "waiting for fritzbox to come up"
while ! ping -c1 www.google.com &>/dev/null; do : sleep 1; done
echo "FRITZ!Box up"

source : https://gist.github.com/pjvds/b88f51a3d5f6e5f0718a#file-reset_fritzbox-sh

Bonjour,
De quelle « box » parlez-vous ?
La box jeedom ?
Il existe une « fonction » de scénario pour faire la même chose.

J’ai ajouté la précision : Box internet / Routeur Fritzbox mais je pensais qu’au vu du code, ce serait compris :wink:

Bon, j’ai réussi à redémarrer ma box en retirant &>/dev/null ici :

Avant

if ! ping -c1 $BOX &>/dev/null; then
 echo "couldn't find fritzbox"
 exit
fi

Après

if ! ping -c1 $BOX ; then
 echo "couldn't find fritzbox"
 exit
fi

Ce sujet a été automatiquement fermé après 24 heures suivant le dernier commentaire. Aucune réponse n’est permise dorénavant.