Why does a shell script fail in crontab?

David Goodenough dg at lakart.UUCP
Sun Oct 16 01:22:34 AEST 1988


I have a shell script ( /usr/local/dopath ) that has the job of updating
our UUCP map files every day at 7:00 AM. There is only one problem with it:
when it runs from crontab it produces a zero size Index file, yet when I
run it by hand from a uid 0 shell it succedes, and generates the correct
Index file. Here is the crontab entry:

0 7 * * *	root	/usr/local/dopath

and here is the contents of that same file:

#! /bin/sh
#
# first get the new map stuff from comp.mail.maps
#
umask 022
cd /usr/spool/maps
ln /usr/spool/news/comp/mail/maps/* .
/usr/local/unshar -c * 2>&1 >/dev/null
cp [ud].* /usr/lib/uucp/uumap
rm -f *
#
# Next get the temp stuff out of news.config
#
cd /usr/lib/uucp/uumap
rm -f d.Temp
/usr/local/getcon /usr/spool/news/news/config/* >d.Temp
#
# now build the path file
#
rm -f UUPATH
/usr/local/pathalias u.[A-Z]* d.* u.[a-z]* 2>/dev/null | \
    /usr/local/pathfilt | sort -u > UUPATH
#
# finally make the index
#
rm -f Index
bm "#N" [du].* | sed 's/:#N/ /' | tr -s '\011, ' ' ' | \
    awk '{ for (i = NF; i > 1; --i) printf "%s\t%s\n", $i, $1 }' | \
    sort -u > Index
#
chown uucp *
chmod 644 [ud].* UUPATH Index

--------
The thing I don't understand is that UUPATH is generated just fine, whereas
Index is only generated when I run this by hand. Note: this is a setuid
root shell script - yes I am aware of the possible security leak, but there
are only two people who use lakart that are unix.wizards, and we both know
the root password. I'm baffled to all H**L on this one - can anyone else
shed some light?
-- 
	dg at lakart.UUCP - David Goodenough		+---+
							| +-+-+
	....... !harvard!xait!lakart!dg			+-+-+ |
AKA:	dg%lakart.uucp at harvard.harvard.edu	  	  +---+



More information about the Comp.unix.questions mailing list