[PLUG] Shell script error explanation needed
Steve Dum
dr.doom at frontier.com
Thu Aug 11 17:49:51 UTC 2016
To answer your question about how the error can be at line 67 when the
script only has 5 lines,
realize that at adds a bunch of stuff at the top of the script - from
the man page of the at on my machine:
The working directory, the environment (except for the variables
BASH_VERSINFO,
DISPLAY, EUID, GROUPS, SHELLOPTS, TERM, UID, and _) and the
umask are retained from
the time of invocation.
so there is easily another 60+ lines to restore your environment to what
it was when you ran at.
If you changed your test script to read from a non existent file say,
test-mail.list924 you should see
the error again.
I suspect the required facts to explain the failure are
1. what directory is the real mail.list file in?
2. what directory are you in when you submit the at job?
to be safe, you could add to the top of the script
cd <directory where mail.list is found>
if you have root access, the easiest way to see what the script is, that
at will be executing is to
go into /var/spool/at and copy the script elsewhere, to examine or play
with.
On my system /var/spool/at has a directory named spool and the at jobs
were of the form
a<some long number> I assume the number encodes a sequence number and
launch time.
do somthing like
sudo bash
ls /var/spool/at
cp /var/spool/at/a0001601761670 /tmp/foo
chown rshepard /tmp/foo
exit
where of course the a0001601761670 is really whatever you see as a job
name from the ls.
You could also write out info to a file from the batch job, like out
from env, $PWD or even try cat'ing $0
but the scripts at generate on my system seem to make $0 (the name of
the script being executed) useless,
as the actual at script generated, does all the setup then pipes the
script into a shell.
steve
Rich Shepard wrote:
> On Thu, 11 Aug 2016, chris (fool) mccraw wrote:
>
>> Be that as it may, the shell script would have said "/path/to/mail.list -
>> file not found" if it was *using* that full path, so you are still (IMHO)
>> looking for an unqualified pathname use.
> The test script ran correctly.
>
> test-1.sh:
>
> #!/bin/bash
>
> while read LINE; do
> ADDR=$(echo $LINE | cut -d: -f1)
> GRTG=$(echo $LINE | cut -d: -f2)
> m4 -D GREETING="$GRTG" test-1.m4 | mail -s 'Testing 1, 2, 3' $ADDR
> done < test-mail.list
>
> test-1.m4:
>
> GREETING:
>
> This is a test message. That's all.
>
> test-mail.list:
>
> rshepard at twodogs.us:Rich
> rshepard at twodogs.us:Rich
> rshepard at twodogs.us:Rich
> rshepard at twodogs.us:Rich
> rshepard at twodogs.us:Rich
> rshepard at twodogs.us:Rich
> rshepard at twodogs.us:Rich
> rshepard at twodogs.us:Rich
> rshepard at twodogs.us:Rich
> rshepard at twodogs.us:Rich
> rshepard at twodogs.us:Rich
> rshepard at twodogs.us:Rich
>
> command issued:
>
> at -f ~/test-1.sh 08:40 am
>
> I just verified that leaving off the '-f' flag prevents the command from
> being added to the at queue; the shell reports:
>
> syntax error. Last token seen: /
> Garbled time
>
> Wonder what happened.
>
> Thanks,
>
> Rich
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>
More information about the PLUG
mailing list