From owner-freebsd-questions Mon Sep 30 21:20:51 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id VAA24894 for questions-outgoing; Mon, 30 Sep 1996 21:20:51 -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 VAA24882 for ; Mon, 30 Sep 1996 21:20:34 -0700 (PDT) Received: by dg-rtp.dg.com (5.4R3.10/dg-rtp-v02) id AA24658; Tue, 1 Oct 1996 00:20:01 -0400 Received: from ime.net by dg-rtp.dg.com.rtp.dg.com; Tue, 1 Oct 1996 00:20 EDT Received: from dg-rtp.UUCP (uucp@localhost) by ponds.water.net (8.7.5/8.7.3) with UUCP id TAA06361 for freebsd.org!questions; Mon, 30 Sep 1996 19:26:10 -0400 (EDT) Received: from ime.net by dg-rtp.dg.com (5.4R3.10/dg-rtp-v02) id AA28970; Mon, 30 Sep 1996 13:01:30 -0400 Received: from kimiko.cguy.com (buxton-6.ime.net [206.231.148.135]) by ime.net (8.7.4/8.6.12) with ESMTP id NAA24054; Mon, 30 Sep 1996 13:01:26 -0400 (EDT) Message-Id: <199609301701.NAA24054@ime.net> From: "Gary Chrysler" To: "Thomas David Rivers" , Subject: Re: sh shell script help needed! Date: Mon, 30 Sep 1996 13:01:07 -0400 X-Msmail-Priority: Normal X-Priority: 3 X-Mailer: Microsoft Internet Mail 4.70.1155 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1 Sender: owner-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk I thank you for the explanation, Though it turned out to be the fact that I use a csh (tcsh) shell. The addition of: #!/bin/sh, Solved my troubles! The missing ';' was actually a typo. -Enjoy Gary ~~~~~~~~~~~~~~~~ Improve America's Knowledge... Share yours The Borg... Where minds meet (207) 929-3848 ---------- > From: Thomas David Rivers > To: tcg@ime.net; ponds!freebsd.org!questions@dg-rtp.dg.com > Subject: Re: sh shell script help needed! > Date: Monday, September 30, 1996 9:16 AM > > > > > > > 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