From owner-freebsd-questions Mon Dec 16 5:18:22 2002 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 CBBDD37B401 for ; Mon, 16 Dec 2002 05:18:20 -0800 (PST) Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2B3DC43ED4 for ; Mon, 16 Dec 2002 05:18:18 -0800 (PST) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-b134.otenet.gr [212.205.244.142]) by mailsrv.otenet.gr (8.12.6/8.12.6) with ESMTP id gBGDI8Ms000675 for ; Mon, 16 Dec 2002 15:18:10 +0200 (EET) Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.12.6/8.12.6) with ESMTP id gBGDB1cV000692 for ; Mon, 16 Dec 2002 15:11:04 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by gothmog.gr (8.12.6/8.12.6/Submit) id gBGD5VUk020616; Mon, 16 Dec 2002 15:05:31 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Mon, 16 Dec 2002 15:05:31 +0200 From: Giorgos Keramidas To: Nelis Lamprecht Cc: questions@freebsd.org Subject: Re: Broken Startup Script Message-ID: <20021216130531.GE12261@gothmog.gr> References: <1040035528.444.5.camel@enigma.8ball.co.za> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1040035528.444.5.camel@enigma.8ball.co.za> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2002-12-16 12:45, Nelis Lamprecht wrote: > > Since upgrading to latest stable a few of my startup scripts have > stopped working due to the changes in sh. I have fixed most but not > sure how to fix the below script which keeps giving me [: > /usr/local/sbin/snmpd: unexpected operator > #!/bin/sh > > if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then > echo "$0: Cannot determine the PREFIX" >&2 > exit 1 > fi > > case "$1" in > start) > [ -x ${PREFIX}/sbin/snmpd -c ${PREFIX}/share/snmp/snmpd.conf ] && > ${PREFIX}/sbin/snmpd && echo -n ' snmpd' > ;; If you were trying to combine two tests in one, this is the wrong way of doing it. You should at least change it to: [ -x ${PREFIX}/sbin/snmpd ] && [ -c ${PREFIX}/share/snmp/snmpd.conf ] && \ ${PREFIX}/sbin/snmpd && echo -n ' snmpd' But even then, the test of the second [...] block is completely bogus, since -c checks whether its operand is a 'character special device'. I'm positively sure that's not what you meant to test. If, on the other hand, you are trying to fire up snmpd with a -c option that points to the proper configuration file that snmpd will read, you should write this a bit differently: [ -x ${PREFIX}/sbin/snmpd ] && \ ${PREFIX}/sbin/snmpd -c ${PREFIX}/share/snmp/snmpd.conf && \ echo -n ' snmpd' That should work better. You could even make things a little more verbose, to avoid making mistakes in the future, and write this using an ``if'' block and quoting the places where $PREFIX is used: if [ -x "${PREFIX}/sbin/snmpd" ]; then "${PREFIX}/sbin/snmpd" -c "${PREFIX}/share/snmp/snmpd.conf" && \ echo -n ' snmpd' fi - Giorgos To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message