Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Apr 2003 15:21:09 -0700
From:      Jim <jconner@enterit.com>
To:        Gerard Samuel <gsam@trini0.org>, FreeBSD Questions <questions@freebsd.org>
Subject:   Re: [mail_lists] My first shell script
Message-ID:  <200304202122.h3KLMXHo010559@quasi.concon.homeip.net>
In-Reply-To: <3EA04475.6060408@trini0.org>
References:  <3EA04475.6060408@trini0.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 18 April 2003 11:31, Gerard Samuel wrote:

I would make it more manageable by changing some of the directories you have 
in there to variables so that it could be edited more quickly.  See below for 
example:

#!/bin/sh
#
# To populate dev team mailinglist archive
#

date=`date '+%Y-%m'`
mhonarc_bin="/usr/local/bin/mhonarc"
chown_bin="/usr/bin/chown"
ecartis_base="/usr/local/ecartis"
list_archive="/files/www/data/list_archive/$date"
mbox="$ecartis_base/lists/dev-team/archives/mbox/dev-team.$date"
chown_args="-R www.www $list_archives"
mhonarc_args="-outdir $list_archives -add $mbox"

if [ ! -d $list_archive ]
then
    if [ -s $mbox ]
    then
        mkdir $list_archives
    fi
fi

$mhonarc_bin $mhonarc_args
$chown_bin $chown_args

exit 0


| Well I had just installed mhonarc to turn a mailling list archive into
| html, and didn't know how to make the
| process automagic.
| I never wrote a shell script from scratch before, and came up with this
| after a brief search on Google for commands.
| It does work, but Im just looking for critical comments to the script,
| to see if I can improve on it..
| If not, its in the archive for others to use it.
| Thanks
| ------------------------------------
| #!/bin/sh
| #
| # To populate dev team mailinglist archive
| #
|
| date=`date '+%Y-%m'`
|
| if test ! -d /files/www/data/list_archive/$date
| then
|     if test -s
| /usr/local/ecartis/lists/dev-team/archives/mbox/dev-team.$date
|     then
|         mkdir /files/www/data/list_archive/$date
|         /usr/local/bin/mhonarc -outdir
| /files/www/data/list_archive/$date
| /usr/local/ecartis/lists/dev-team/archives/mbox/dev-team.$date
|         chown -R www:www /files/www/data/list_archive/$date
|     fi
|     exit
| else
|     /usr/local/bin/mhonarc -outdir /files/www/data/list_archive/$date
| -add /usr/local/ecartis/lists/dev-team/archives/mbox/dev-team.$date
|     chown -R www:www /files/www/data/list_archive/$date
| fi
| exit 0
|
| _______________________________________________
| freebsd-questions@freebsd.org mailing list
| http://lists.freebsd.org/mailman/listinfo/freebsd-questions
| To unsubscribe, send any mail to
| "freebsd-questions-unsubscribe@freebsd.org"

-- 

- Jim



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304202122.h3KLMXHo010559>