Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[HS] Cron et Expect (Résolu)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index French
View previous topic :: View next topic  
Author Message
404_crazy
Tux's lil' helper
Tux's lil' helper


Joined: 22 Jan 2008
Posts: 145

PostPosted: Mon May 12, 2014 7:57 pm    Post subject: [HS] Cron et Expect (Résolu) Reply with quote

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
View user's profile Send private message
DuF
Advocate
Advocate


Joined: 09 Dec 2002
Posts: 2687
Location: Paris

PostPosted: Tue May 13, 2014 5:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
404_crazy
Tux's lil' helper
Tux's lil' helper


Joined: 22 Jan 2008
Posts: 145

PostPosted: Wed May 14, 2014 5:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
DuF
Advocate
Advocate


Joined: 09 Dec 2002
Posts: 2687
Location: Paris

PostPosted: Fri May 16, 2014 11:19 am    Post subject: Reply with quote

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
View user's profile Send private message
404_crazy
Tux's lil' helper
Tux's lil' helper


Joined: 22 Jan 2008
Posts: 145

PostPosted: Fri May 16, 2014 12:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum