From owner-freebsd-questions@FreeBSD.ORG Sun Apr 20 15:17:57 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3E11037B401 for ; Sun, 20 Apr 2003 15:17:57 -0700 (PDT) Received: from quasi.concon.homeip.net (adsl-67-116-217-192.dsl.sndg02.pacbell.net [67.116.217.192]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6444B43FDD for ; Sun, 20 Apr 2003 15:17:56 -0700 (PDT) (envelope-from jconner@enterit.com) Received: from there (snafux [192.168.100.13])h3KLMXHo010559; Sun, 20 Apr 2003 17:22:35 -0400 Message-Id: <200304202122.h3KLMXHo010559@quasi.concon.homeip.net> Content-Type: text/plain; charset="iso-8859-1" From: Jim To: Gerard Samuel , FreeBSD Questions Date: Sun, 20 Apr 2003 15:21:09 -0700 X-Mailer: KMail [version 1.3.2] References: <3EA04475.6060408@trini0.org> In-Reply-To: <3EA04475.6060408@trini0.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: Re: [mail_lists] My first shell script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: jconner@enterit.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Apr 2003 22:17:57 -0000 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