Date: Thu, 11 May 2000 00:45:43 -0400 From: "Crist J. Clark" <cjc@cc942873-a.ewndsr1.nj.home.com> To: Duke Normandin <dnormandin@freewwweb.com> Cc: "'freebsd-questions@FreeBSD.org'" <freebsd-questions@FreeBSD.ORG> Subject: Re: csh script syntax error Message-ID: <20000511004543.A32949@cc942873-a.ewndsr1.nj.home.com> In-Reply-To: <000801bfbadf$b95fcd40$fbdba7d1@dnormandinfreewwweb.com>; from dnormandin@freewwweb.com on Wed, May 10, 2000 at 06:07:34PM -0600 References: <000801bfbadf$b95fcd40$fbdba7d1@dnormandinfreewwweb.com>
index | next in thread | previous in thread | raw e-mail
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
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000511004543.A32949>
