Alternatives to run-parts ?
Ciao,
someone can explain the difference between run-parts and:
-----------8<-----------
#!/bin/sh
# alternative to run-parts ..... (?)
USAGE="\
Usage: $0 dirname\n
run all the executable inside the directory <dirname>
"
if [ "$2" = "test" ] ; then
TEST=1
else
TEST=0
fi
if [ $# = 0 ] ; then
# no arguments
echo -e $USAGE
exit 1
fi
if [ ! -d $1 ] ; then
echo "Error, $1 isn't a directory."
exit 1
fi
DIR=$1
FILELIST=`ls $1`
# echo $FILELIST
for FILE in $FILELIST ; do
FILENAME=${DIR}/$FILE
# executable? AND real file ? (not directory...)
if [ -x $FILENAME -a -f $FILENAME ] ; then
echo "Executing $FILENAME"
if [ $TEST = 0 ] ; then
. $FILENAME
fi
else
echo "$FILENAME is not a file or is not executable."
fi
done
exit 0
-----------8<-----------
I prefer a script rather then a binary file, if they can do the same
things...
The reason of this is that if I don't want execute a script-file during the
cron time (daily/weekly/montly) I simply do:
chmod -x script-file
but cron (using run-parts) tell me:
/etc/cron.daily/leafnode:
run-parts: failed to exec /etc/cron.daily/leafnode: Permission denied
run-parts: /etc/cron.daily/leafnode exited with return code 1
/etc/cron.daily/man-db:
run-parts: failed to exec /etc/cron.daily/man-db: Permission denied
run-parts: /etc/cron.daily/man-db exited with return code 1
/etc/cron.daily/slrn:
run-parts: failed to exec /etc/cron.daily/slrn: Permission denied
run-parts: /etc/cron.daily/slrn exited with return code 1
/etc/cron.daily/wwwoffle:
run-parts: failed to exec /etc/cron.daily/wwwoffle: Permission denied
run-parts: /etc/cron.daily/wwwoffle exited with return code 1
Right! Because all this scripts are no more executable, but still exist in
that directory:
/etc/cron.daily# dir
-rwxr-xr-x 1 root root 277 mag 14 1998 0anacron*
-rwxr-xr-x 1 root root 2307 ago 14 14:20 apache*
-rwxr-xr-x 1 root root 449 gen 13 00:09 calendar*
-rw-r--r-- 1 root root 421 dic 18 21:56 leafnode
-rw-r--r-- 1 root root 235 mag 15 1998 man-db
-rwxr-xr-x 1 root root 180 mag 23 1998 mgetty*
-rwxr-xr-x 1 root root 487 mag 18 1997 netbase*
-rw-r--r-- 1 root root 481 feb 21 1998 slrn
-rwxr-xr-x 1 root root 435 lug 16 1998 smail*
-rwxr-xr-x 1 root root 1367 apr 26 1998 standard*
-rwxr-xr-x 1 root root 660 apr 16 1998 sysklogd*
-rwxr-xr-x 1 root root 114 giu 15 1998 tetex-bin*
-rwxr-xr-x 1 root root 277 mar 20 1998 updatedb*
-rw-r--r-- 1 root root 702 gen 13 00:02 wwwoffle
Do I wrong something/somewhere?
--
Paolo Pedaletti, Como, ITALYa
paolop@mmpoint.it
Reply to: