From owner-freebsd-questions Mon Sep 30 10:10:50 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id KAA25097 for questions-outgoing; Mon, 30 Sep 1996 10:10:50 -0700 (PDT) Received: from dg-rtp.dg.com (dg-rtp.rtp.dg.com [128.222.1.2]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id KAA25033 for ; Mon, 30 Sep 1996 10:10:44 -0700 (PDT) Received: by dg-rtp.dg.com (5.4R3.10/dg-rtp-v02) id AA26601; Mon, 30 Sep 1996 12:20:15 -0400 Received: from ponds by dg-rtp.dg.com.rtp.dg.com; Mon, 30 Sep 1996 12:20 EDT Received: from lakes.water.net (lakes [10.0.0.3]) by ponds.water.net (8.7.5/8.7.3) with ESMTP id JAA26334; Mon, 30 Sep 1996 09:16:52 -0400 (EDT) Received: (from rivers@localhost) by lakes.water.net (8.7.5/8.6.9) id JAA02770; Mon, 30 Sep 1996 09:16:31 -0400 (EDT) Date: Mon, 30 Sep 1996 09:16:31 -0400 (EDT) From: Thomas David Rivers Message-Id: <199609301316.JAA02770@lakes.water.net> To: tcg@ime.net, ponds!freebsd.org!questions Subject: Re: sh shell script help needed! Content-Type: text Sender: owner-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > > > What am I doing wrong here?? (Yes, I know it's me :) > Such a simple thing and I can't get it to work! > > # test script > # based on /etc/rc usage of if > if [ $1 = yes ] then Here's your problem.. the 'then' part of an 'if' must be on a separate 'line'. This can be accomplished by physically moving the then to the next line (which is what I prefer) or by inserting the ';' separator... As in: if [ $1 = yes ] then echo Yes fi or if [ $1 = yes ] ; then echo Yes fi Now, your next question should be "That seems pretty dumb - why is it so?" The problem is that (logically, if not actually) the 'if' statement actually runs a program, in this instance, a program named '[' which is a link to a program named 'test'. This program is presumed to accept arguments, which are in your case "$1 = yes ]". (Note that ']' is not the close of '[', it is an (ignored) argument to the 'test' program.) So, the shell needs to determine when the arguments are over, and where the 'then' is. You do that by inserting a command separator (the ';') or by putting the 'then' on the next line. Hope this helps - Dave Rivers - > ramillia {1377} ./test yes > if: Expression Syntax > ramillia {1378} > > Such an easy thing... ... I've tried every variation I can think of while > crusing through stuff in /etc > > Thanks. > > -Enjoy > Gary