LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-03-2018, 11:46 AM   #1
rbees
Member
 
Registered: Mar 2004
Location: northern michigan usa
Distribution: Debian Squeeze, Whezzy, Jessie
Posts: 921

Rep: Reputation: 46
/bin/sh not linking to bash correctly?


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
Code:
$ bash debug.sh
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
 
Old 09-03-2018, 01:07 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
When bash is invoked with the name "sh" it mimics the behavior of historical versions of sh. Your symlink doesn't change that. bash will still see argv[0]=="/bin/sh" and revert to the historical behavior.
 
Old 09-03-2018, 02:11 PM   #3
rbees
Member
 
Registered: Mar 2004
Location: northern michigan usa
Distribution: Debian Squeeze, Whezzy, Jessie
Posts: 921

Original Poster
Rep: Reputation: 46
thanks rknichols,

But that does not help me solve my problem.

Yet this at job runs correctly and it contains the !#/bin/sh
Code:
JOB 1768
#!/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
}
/home/pi/bin/shabbat/NewCandleTime 2>&1 | tee /home/pi/bin/shabbat/data/09_03_2018debug.txt
It also contains several lines just like the one that fails in the other script.

Please explain
 
Old 09-03-2018, 03:21 PM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Just fix the first line of your script:
Code:
#!/bin/bash
http://tldp.org/LDP/abs/html/process-sub.html

Last edited by NevemTeve; 09-03-2018 at 03:25 PM.
 
Old 09-03-2018, 03:28 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
What was the command line that invoked that script? If it was invoked by "bash /path/to/script ...", then bash is the interpreter and that first line is just a comment that is ignored. If it was invoked simply by its name, "/path/to/script ...", then the kernel should have used /bin/sh as the interpreter.

Put an "echo $0 $BASH_VERSION >&2" as the second line so that you can see what shell is being used.
 
Old 09-03-2018, 04:48 PM   #6
rbees
Member
 
Registered: Mar 2004
Location: northern michigan usa
Distribution: Debian Squeeze, Whezzy, Jessie
Posts: 921

Original Poster
Rep: Reputation: 46
Thanks NevemTeve

To clarify the script that you are looking at is generated by "at" and copied directly from what is run by "at" when it is scheduled to run. So it is not possible for me to just change the first line of the script. Also the name, in this case list3.sh is a name I gave it for debugging purposes. It is obtained with
Code:
#!/bin/bash
MAXJOB=$(atq | head -n1 | awk '{ print $1; }')
for each in $(atq | cut -f 1); do echo "JOB $each"; at -c $each; done
and I copied the relevant section out to list3.sh. So my best guess it is what is actually executed by /bin/sh when it is run.

rknichols

Code:
pi@raspberrypi:~/bin $ list3.sh
/home/pi/bin/list3.sh 4.4.12(1)-release
/home/pi/bin/list3.sh: line 56: syntax error near unexpected token `<'
/home/pi/bin/list3.sh: line 56: `read DAYNAME< <(date -d $YEAR-$MONTH-$DAY +%a)'
The system is Raspbian Stretch full desktop on a pi3b+ patched regularly. No special tweaks other than changing the /bin/sh to point to bash instead of dash.

Path to the script:
NewCandleTime (run initially manually) > generating an "at" job to run at 5:15pm to pull a specific url (that changes randomly) off the Internet (and so has no specific name that I am aware of) among other "at" jobs throughout the week which are time specific to sundown > using that data schedule several "at" jobs to run over the next 24 hours (fails here, there again no specific name). At the end of the week at 2:05am (to avoid daylight savings time issue) schedule the next weeks run of NewCandleTime.

NewCandleTime contains several line just like the one that fail in list3.sh yet it run normally when executed by "at". Both before and after the change to /bin/sh.
 
Old 09-04-2018, 01:47 AM   #7
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,792

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
Changing /bin/sh has a great impact on the system() calls, including the system boot process. Fortunately bash in /bin/sh mode is "quite" compatible. Always?
If you only want bash for the at jobs, invoke it with the environment variable SHELL set (see "man at")
Code:
SHELL=/bin/bash at ...

Last edited by MadeInGermany; 09-04-2018 at 02:03 AM.
 
Old 09-04-2018, 03:17 AM   #8
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Regarding at(1) here is my suggestion (put the name of your script into the first line):
Code:
BashScript=at-start.bash
BashScPt="$(realpath "$BashScript")"
echo "exec '$BashScPt'" | at 'now + 1 min'

Last edited by NevemTeve; 09-04-2018 at 03:18 AM.
 
Old 09-04-2018, 11:24 AM   #9
rbees
Member
 
Registered: Mar 2004
Location: northern michigan usa
Distribution: Debian Squeeze, Whezzy, Jessie
Posts: 921

Original Poster
Rep: Reputation: 46
Thanks MadeInGermany & NevemTeve

I am not sure how I would change the script to make use of your suggestions. So I modified it in a different way and remove the offending line even though I still don't, but would like to, understand why it works in one script and not the other.

I changed
Code:
# Set up the service times for the comming week
read DAYNAME< <(date -d $YEAR-$MONTH-$DAY +%a)

    if [[ "$DAYNAME" != Fri ]];then
To
Code:
if [[ $(date +%a) != Fri ]];then
Code:
pi@raspberrypi:~/bin $ sh debug.sh
http://s6.voscast.com:9464
warning: commands will be executed using /bin/sh
job 1798 at Tue Sep  4 17:25:00 2018
.
.
Not sure why it was not that way in the first place, but then I am not really a programmer. I have to get by with copy/paste then figure out how to make it work with help from this site and others.

Anyway Thanks again to all who help others on this site.
 
Old 09-04-2018, 11:41 AM   #10
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Process substitution only works in bash (called as "bash" not as "sh")
eg:
Code:
bash -c 'cat <(echo Hi)' -- OK
dash -c 'cat <(echo Hi)' -- Syntax error
 
Old 09-04-2018, 12:43 PM   #11
rbees
Member
 
Registered: Mar 2004
Location: northern michigan usa
Distribution: Debian Squeeze, Whezzy, Jessie
Posts: 921

Original Poster
Rep: Reputation: 46
This I understand. Yet the main script is loaded and processed by sh and it contains "process substitution" and works correctly.
 
Old 09-04-2018, 02:12 PM   #12
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
It's either a miracle, or it was still executed by bash, or perhaps you didn't check the error messages carefully enough.

Last edited by NevemTeve; 09-04-2018 at 02:14 PM.
 
Old 09-05-2018, 02:03 AM   #13
rbees
Member
 
Registered: Mar 2004
Location: northern michigan usa
Distribution: Debian Squeeze, Whezzy, Jessie
Posts: 921

Original Poster
Rep: Reputation: 46
Right out of the log from when it runs
Code:
+ CURENTMONTH=Elul
++ hdate -t -L-87.038894 -l41.474079 -z-5:00 12 08 2018
++ awk '/sunrise/{print $2}'
+ MORNOMER=05:53
+ read DAY MONTH YEAR hour min
date -d "$YEAR-$MONTH-$DAY $MORNOMER$TZ -5minutes" "+%d %m %Y %H %M"
++ date -d '2018-08-12 05:53-5:00 -5minutes' '+%d %m %Y %H %M'
+ [[ Elul == \N\i\s\a\n ]]
+ [[ Elul == \I\y\y\a\r ]]
+ [[ Elul == \S\i\v\a\n ]]
+ Havdalah
and this was from before I edited /bin/sh

I could post the entire log with included code but it is some 4000 lines long.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Combine two or more bin files into another bin file at specific addresses in bash WSRaptor Programming 1 04-20-2015 02:36 PM
[SOLVED] /usr/bin/xterm: Could not exec /bin/bash: Permission Denied suheng Linux - Newbie 2 09-24-2010 05:31 PM
linking applications to /usr/bin imnah Linux - Newbie 4 02-28-2007 05:03 PM
Compiling GLIBC, and linking it correctly Boudewijn Linux - Newbie 5 11-08-2004 11:11 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration