From owner-freebsd-questions Wed May 10 21:47:17 2000 Delivered-To: freebsd-questions@freebsd.org Received: from cc942873-a.ewndsr1.nj.home.com (cc942873-a.ewndsr1.nj.home.com [24.2.89.207]) by hub.freebsd.org (Postfix) with ESMTP id E0F6237B758 for ; Wed, 10 May 2000 21:47:10 -0700 (PDT) (envelope-from cjc@cc942873-a.ewndsr1.nj.home.com) Received: (from cjc@localhost) by cc942873-a.ewndsr1.nj.home.com (8.9.3/8.9.3) id AAA33745; Thu, 11 May 2000 00:45:43 -0400 (EDT) (envelope-from cjc) Date: Thu, 11 May 2000 00:45:43 -0400 From: "Crist J. Clark" To: Duke Normandin Cc: "'freebsd-questions@FreeBSD.org'" Subject: Re: csh script syntax error Message-ID: <20000511004543.A32949@cc942873-a.ewndsr1.nj.home.com> Reply-To: cjclark@home.com References: <000801bfbadf$b95fcd40$fbdba7d1@dnormandinfreewwweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <000801bfbadf$b95fcd40$fbdba7d1@dnormandinfreewwweb.com>; from dnormandin@freewwweb.com on Wed, May 10, 2000 at 06:07:34PM -0600 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, May 10, 2000 at 06:07:34PM -0600, Duke Normandin wrote: > I'm running 3.3R... > The following script ( a port from tcsh) fails with the error message > if: expression syntax error > > #!/bin/csh > # > if ( mv $* ~/tmp ) then > echo "The files have been moved! To remove them " > echo "use the 'purge' command " > else > echo "Something's haywire! Files not moved. " > endif > > I can't figure this puppy out! Tia..... > > -duke First... DO NOT USE CSH FOR SCRIPTS. Use /bin/sh. (And I use tcsh for my interactive shells, wouldn't dream of writing scripts in it.) #!/bin/sh # if mv $* ~/tmp; then echo "The files have been moved! To remove them " echo "use the 'purge' command " else echo "Something's haywire! Files not moved. " fi Second, if some evil force is compelling you to use csh, RTFM, csh(1), Expressions Several of the builtin commands (to be described later) take expressions, in which the operators are similar to those of C, with the same prece- dence. These expressions appear in the @, exit, if, and while commands. . . . Also available in expressions as primitive operands are command execu- tions enclosed in `{' and `}'... So, if you were actually to use csh, you want, #!/bin/csh # if { mv $* ~/tmp } then echo "The files have been moved! To remove them " echo "use the 'purge' command " else echo "Something's haywire! Files not moved. " endif -- Crist J. Clark cjclark@home.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message