On 2016-04-04 19:22, Carlos E. R. wrote:
On 04/04/2016 15:47, Dave Howorth wrote:
On 2016-04-04 14:34, Carlos E. R. wrote:
I have my main computer voice the time every half hour, running from a cron job. Unfortunately it fails often for reasons I don't have clear. It is related to ownership of the sound devices by the user in the seat; the scripts are run by root.
If you su root and run the job from a terminal, you'll see the error messages. IIRC it can't connect to the dbus.
Nope, because the error is also related to been run from cron, without a terminal. I can tell it to mail whatever errors it sees, though.
But that was not the main problem, I did see the error messages, just that I couldn't solve the issue. I'll try again later and give more information here. Last time I tried was many months ago, so I may be wrong in my recollections ;-)
Ok, this is what I have currently: /etc/cron.d/mine: 0,30 * * * * cer /home/cer/bin/dar_la_hora_en_cron hora /home/cer/bin/dar_la_hora_en_cron: #!/bin/bash TEMPORAL=`mktemp /tmp/decir.wav.XXXXXXXXXXXXX` ERROR=$? case $ERROR in 0) ;; *) echo "Error $ERROR in mktemp" exit ;; esac #set | grep TERM #Sale "TERM=dumb" case "$1" in time) /bin/date +"%B %e, %k hours %-M minutes " | espeak -v en --stdin -a 20 -w $TEMPORAL ;; hora) LANG=es_ES.UTF-8 LC_ALL=es_ES.UTF-8 /bin/date +"Es %e de %B, y son las %k horas y %-M minutos " | espeak -v es --stdin -a 20 -w $TEMPORAL ;; *) echo -e "Error de entrada en $0" exit ;; esac if test -f $TEMPORAL ; then echo "CER: using gst123 --------------" >> /tmp/dar_la_hora_en_cron.log 2>&1 /usr/bin/gst123 --quiet $TEMPORAL >> /tmp/dar_la_hora_en_cron.log 2>&1 rm $TEMPORAL fi So. It is a cron job running every half hour a script that speaks the time. The script is prepared to give the time in Spanish or English, and works fine on a terminal. The cron job is run by the same user that typically has the seat. I echo the time string to "espeak", which generates a wave file, that has to be reproduced on the speaker on a second step. Currently I use "gst123" to do that. However, the cronjob does not always play. For instance, now it is playing. It only writes this error: tput: No value for $TERM and no -T specified As I have in a comment in the script, "TERM=dumb" If I remove --quiet, then the output is: tput: No value for $TERM and no -T specified The not quiet output is this one: ............... tput: No value for $TERM and no -T specified Playing file:///tmp/decir.wav.5mmgfymNHCEkB Codec : Uncompressed 16-bit PCM audio Bitrate : 0.0 kbit/s .................. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)