As always thanks to those that help others on this site.
I am having an issue with a bash script. I have posted many references to this script in this forum. At one time this part of it was working correctly but some changes were made and now it does not. I do not remember what those changes were and now it is running on a pi and I don't seam to be able to get it to work correctly again.
Brief overview of what it does. It schedules specific commands to run at specific times related to when sundown is so "cron" will not work and "at" must be used. It self replicates every sunday after 2:05 am so that daylight savings time does not interfere with its scheduling.
Code:
now=$(date +"%m_%d_%Y")
echo "$BINDIR/NewCandleTime 2>&1 | tee $STORDIR/"$now"debug.txt" | at 2:05AM next sunday
One of the jobs it schedules can not take place before a certain time on Friday as the url it pulls from the internet gets changed without notice and that causes the event the next day to fail. So the url is pulled just prior to the time it is first needed and the events for the next day are then scheduled at that time. This is the part that is failing.
list3.sh is copied directly out of the scheduled at command to create the test file. Included below.
The line that is failing is
Code:
read DAYNAME< <(date -d $YEAR-$MONTH-$DAY +%a)
And fail with this message
Code:
pi@raspberrypi:~/bin $ list3.sh
/home/pi/bin/list3.sh: line 55: syntax error near unexpected token `<'
/home/pi/bin/list3.sh: line 55: `read DAYNAME< <(date -d $YEAR-$MONTH-$DAY +%a)'
I have read that /bin/sh normally points to dash instead of bash and this is a cause of this type of error. So I deleted the symlink /bin/sh and replaced it with a symlink to /bin/bash. The above error message is from after that change. As I remember it this is what I did to correct a problem with the script originally but I can't be sure as it was some years ago.
There are other places in the over all script that use very similar lines and they seam to function correctly when run as part of the larger script as can be seen below.
The code section from the overall script
Code:
# Service Setup
#
function Service_Setup {
read DAYNAME< <(date -d $YEAR-$MONTH-$DAY +%a)
if [[ "$DAYNAME" != Fri ]];then
echo "It's not time to set up the service schedule"
return
else
at 5:15pm "$MONTH/$DAY/$YEAR" -f $STORDIR/serviceSetup
fi
}
The job is setup correctly as can be seen here. And it worked correctly before the change to /bin/sh.
Code:
+ Service_Setup
+ read DAYNAME
date -d $YEAR-$MONTH-$DAY +%a
++ date -d 2018-09-07 +%a
+ [[ Fri != Fri ]]
+ at 5:15pm 09/07/2018 -f /home/pi/bin/shabbat/data/serviceSetup
warning: commands will be executed using /bin/sh
job 1721 at Fri Sep 7 17:15:00 2018
If I run the script with
it works fine.
Totally confused.
Code:
#!/bin/sh
# atrun uid=1000 gid=1000
# mail pi 0
umask 22
LS_COLORS=rs=0:di=01\;34:ln=01\;36:mh=00:pi=40\;33:so=01\;35:do=01\;35:bd=40\;33\;01:cd=40\;33\;01:or=40\;31\;01:mi=00:su=37\;41:sg=30\;43:ca=30\;41:tw=30\;42:ow=34\;42:st=37\;44:ex=01\;32:\*.tar=01\;31:\*.tgz=01\;31:\*.arc=01\;31:\*.arj=01\;31:\*.taz=01\;31:\*.lha=01\;31:\*.lz4=01\;31:\*.lzh=01\;31:\*.lzma=01\;31:\*.tlz=01\;31:\*.txz=01\;31:\*.tzo=01\;31:\*.t7z=01\;31:\*.zip=01\;31:\*.z=01\;31:\*.Z=01\;31:\*.dz=01\;31:\*.gz=01\;31:\*.lrz=01\;31:\*.lz=01\;31:\*.lzo=01\;31:\*.xz=01\;31:\*.zst=01\;31:\*.tzst=01\;31:\*.bz2=01\;31:\*.bz=01\;31:\*.tbz=01\;31:\*.tbz2=01\;31:\*.tz=01\;31:\*.deb=01\;31:\*.rpm=01\;31:\*.jar=01\;31:\*.war=01\;31:\*.ear=01\;31:\*.sar=01\;31:\*.rar=01\;31:\*.alz=01\;31:\*.ace=01\;31:\*.zoo=01\;31:\*.cpio=01\;31:\*.7z=01\;31:\*.rz=01\;31:\*.cab=01\;31:\*.jpg=01\;35:\*.jpeg=01\;35:\*.mjpg=01\;35:\*.mjpeg=01\;35:\*.gif=01\;35:\*.bmp=01\;35:\*.pbm=01\;35:\*.pgm=01\;35:\*.ppm=01\;35:\*.tga=01\;35:\*.xbm=01\;35:\*.xpm=01\;35:\*.tif=01\;35:\*.tiff=01\;35:\*.png=01\;35:\*.svg=01\;35:\*.svgz=01\;35:\*.mng=01\;35:\*.pcx=01\;35:\*.mov=01\;35:\*.mpg=01\;35:\*.mpeg=01\;35:\*.m2v=01\;35:\*.mkv=01\;35:\*.webm=01\;35:\*.ogm=01\;35:\*.mp4=01\;35:\*.m4v=01\;35:\*.mp4v=01\;35:\*.vob=01\;35:\*.qt=01\;35:\*.nuv=01\;35:\*.wmv=01\;35:\*.asf=01\;35:\*.rm=01\;35:\*.rmvb=01\;35:\*.flc=01\;35:\*.avi=01\;35:\*.fli=01\;35:\*.flv=01\;35:\*.gl=01\;35:\*.dl=01\;35:\*.xcf=01\;35:\*.xwd=01\;35:\*.yuv=01\;35:\*.cgm=01\;35:\*.emf=01\;35:\*.ogv=01\;35:\*.ogx=01\;35:\*.aac=00\;36:\*.au=00\;36:\*.flac=00\;36:\*.m4a=00\;36:\*.mid=00\;36:\*.midi=00\;36:\*.mka=00\;36:\*.mp3=00\;36:\*.mpc=00\;36:\*.ogg=00\;36:\*.ra=00\;36:\*.wav=00\;36:\*.oga=00\;36:\*.opus=00\;36:\*.spx=00\;36:\*.xspf=00\;36:; export LS_COLORS
LANG=en_US.UTF-8; export LANG
OLDPWD=/home/pi/bin; export OLDPWD
INFINALITY_FT_CHROMEOS_STYLE_SHARPENING_STRENGTH=0; export INFINALITY_FT_CHROMEOS_STYLE_SHARPENING_STRENGTH
INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS=true; export INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS
INFINALITY_FT_CONTRAST=0; export INFINALITY_FT_CONTRAST
INFINALITY_FT_STEM_FITTING_STRENGTH=25; export INFINALITY_FT_STEM_FITTING_STRENGTH
INFINALITY_FT_GLOBAL_EMBOLDEN_X_VALUE=0; export INFINALITY_FT_GLOBAL_EMBOLDEN_X_VALUE
XDG_SESSION_ID=c19; export XDG_SESSION_ID
USER=pi; export USER
INFINALITY_FT_AUTOHINT_SNAP_STEM_HEIGHT=100; export INFINALITY_FT_AUTOHINT_SNAP_STEM_HEIGHT
INFINALITY_FT_GRAYSCALE_FILTER_STRENGTH=0; export INFINALITY_FT_GRAYSCALE_FILTER_STRENGTH
INFINALITY_FT_GAMMA_CORRECTION=0\ 100; export INFINALITY_FT_GAMMA_CORRECTION
PWD=/home/pi/bin/shabbat; export PWD
HOME=/home/pi; export HOME
TEXTDOMAIN=Linux-PAM; export TEXTDOMAIN
INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH=10; export INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH
SSH_TTY=/dev/pts/0; export SSH_TTY
INFINALITY_FT_BRIGHTNESS=0; export INFINALITY_FT_BRIGHTNESS
MAIL=/var/mail/pi; export MAIL
INFINALITY_FT_USE_VARIOUS_TWEAKS=true; export INFINALITY_FT_USE_VARIOUS_TWEAKS
SHLVL=2; export SHLVL
INFINALITY_FT_BOLD_EMBOLDEN_Y_VALUE=0; export INFINALITY_FT_BOLD_EMBOLDEN_Y_VALUE
INFINALITY_FT_GLOBAL_EMBOLDEN_Y_VALUE=0; export INFINALITY_FT_GLOBAL_EMBOLDEN_Y_VALUE
INFINALITY_FT_AUTOHINT_HORIZONTAL_STEM_DARKEN_STRENGTH=10; export INFINALITY_FT_AUTOHINT_HORIZONTAL_STEM_DARKEN_STRENGTH
LOGNAME=pi; export LOGNAME
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus; export DBUS_SESSION_BUS_ADDRESS
XDG_RUNTIME_DIR=/run/user/1000; export XDG_RUNTIME_DIR
PATH=/home/pi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games; export PATH
INFINALITY_FT_FILTER_PARAMS=11\ 22\ 38\ 22\ 11; export INFINALITY_FT_FILTER_PARAMS
INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE=40; export INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE
INFINALITY_FT_USE_KNOWN_SETTINGS_ON_SELECTED_FONTS=true; export INFINALITY_FT_USE_KNOWN_SETTINGS_ON_SELECTED_FONTS
INFINALITY_FT_STEM_ALIGNMENT_STRENGTH=25; export INFINALITY_FT_STEM_ALIGNMENT_STRENGTH
INFINALITY_FT_AUTOHINT_VERTICAL_STEM_DARKEN_STRENGTH=25; export INFINALITY_FT_AUTOHINT_VERTICAL_STEM_DARKEN_STRENGTH
INFINALITY_FT_BOLD_EMBOLDEN_X_VALUE=0; export INFINALITY_FT_BOLD_EMBOLDEN_X_VALUE
INFINALITY_FT_FRINGE_FILTER_STRENGTH=0; export INFINALITY_FT_FRINGE_FILTER_STRENGTH
cd /home/pi/bin/shabbat || {
echo 'Execution directory inaccessible' >&2
exit 1
}
#!/bin/bash
BINDIR="${HOME}/bin/shabbat"
TMPDIR="${HOME}/bin/shabbat/tmp"
STORDIR="${HOME}/bin/shabbat/data"
# Set up the service times for the comming week
read DAYNAME< <(date -d $YEAR-$MONTH-$DAY +%a)
if [[ "$DAYNAME" != Fri ]];then
echo "It's not time to set up the service schedule"
return
else
livestream=$(w3m -dump_source http://www.shaareyzedek.mb.ca/service/serviceslive/audio.htm | grep NAME=FlashVars | grep -Eo '(http)://[^/"]+'|head -1)
echo $livestream
cat << EOF > $TMPDIR/service
stopradio
/usr/sbin/alsactl --file $STORDIR/asound.state store
amixer set Master 50%
sleep 5
mpg123 $BINDIR/music/shofar.mp3
mplayer $livestream
EOF
at 5:25pm today -f $TMPDIR/service
at 6:30pm today -f $BINDIR/stopService
at 9:55AM NEXT SAT -f $TMPDIR/service
at 12:20PM NEXT SAT -f $BINDIR/stopService
at 5:55pm NEXT SAT -f $TMPDIR/service
at 6:45pm NEXT SAT -f $BINDIR/stopService
fi