View previous topic :: View next topic |
Author |
Message |
404_crazy Tux's lil' helper
Joined: 22 Jan 2008 Posts: 145
|
Posted: Mon May 12, 2014 7:57 pm Post subject: [HS] Cron et Expect (Résolu) |
|
|
Salut à tous,
Je cherche un moyen de lancer un script expect depuis mon cron.d...
il semble que cron n'utilise pas de tty donc mon script expect ne peux pas fonctionner..
Voila le script:
Code: | [root@scratoo arduarium]# cat vanneoff.sh
#!/usr/bin/expect -f
spawn screen /dev/ttyACM0 9600
sleep 1
send "vanneoff\r"
expect eof |
Ce script envoi des commandes sur mon arduino...Avez vous une solution ou une idée pour faire cela?
Last edited by 404_crazy on Fri May 16, 2014 3:45 pm; edited 1 time in total |
|
Back to top |
|
|
DuF Advocate
Joined: 09 Dec 2002 Posts: 2687 Location: Paris
|
Posted: Tue May 13, 2014 5:48 pm Post subject: |
|
|
Es-tu sous systemd ? Car par contournement il permet de programmer des tâches (on trouve des tutoriaux sur internet). Cela pourrait répondre à ton problème de manière détournée. |
|
Back to top |
|
|
404_crazy Tux's lil' helper
Joined: 22 Jan 2008 Posts: 145
|
Posted: Wed May 14, 2014 5:23 pm Post subject: |
|
|
Merci de ta réponse DuF;
Donc j'ai fait des tests avec systemd:
J'ai créé un service :
Code: |
[root@scratoo ~]# cat /usr/lib/systemd/system/test.service
[Unit]
Description=Service de test
After=tlp-init.service
[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/usr/local/bin/vanneoff.sh
[Install]
WantedBy=multi-user.target
|
J'ai tenté de le lancer:
Code: | # systemctl start test.service |
...le script ne produit pas ces effets... voila le résultat d'un systemctl status test.service:
Code: |
# systemctl status test.service
* test.service - Service de test
Loaded: loaded (/usr/lib/systemd/system/test.service; disabled)
Active: inactive (dead)
Dec 31 17:11:11 scratoo systemd[1]: Starting Service de test...
Dec 31 17:11:11 scratoo vanneoff.sh[1656]: spawn screen /dev/ttyACM0 9600
[b]Dec 31 17:11:12 scratoo vanneoff.sh[1656]: Please set a terminal type.[/b]
Dec 31 17:11:12 scratoo vanneoff.sh[1656]: vanneoff
Dec 31 17:11:12 scratoo systemd[1]: Started Service de test.
|
La ligne "Please set a terminal type." n’apparaît pas quand je lance le script depuis mon prompt ssh classique.. |
|
Back to top |
|
|
DuF Advocate
Joined: 09 Dec 2002 Posts: 2687 Location: Paris
|
Posted: Fri May 16, 2014 11:19 am Post subject: |
|
|
Bonjour,
Je n'ai pas forcément la réponse à ton problème de manière directe par contre j'ai remis la main sur le tutoriel (en français) que j'avais lu sur le sujet : Remplacer cron par systemd
En espérant que cela t'aide. |
|
Back to top |
|
|
404_crazy Tux's lil' helper
Joined: 22 Jan 2008 Posts: 145
|
Posted: Fri May 16, 2014 12:56 pm Post subject: |
|
|
Salut,
Merci pour la doc mais j'ai finalement trouvé une solution, j'ai fait en python.. c'est très simple avec pyserial:
Code: |
[root@scratoo ~]# cat vanneon.py
import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
ser.write("vanneon\r")
|
|
|
Back to top |
|
|
|