Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Jan 1997 17:05:44 -0800 (PST)
From:      Dan Busarow <dan@dpcsys.com>
To:        Jim Bentley <jimbo@intcomm.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: csh scripting
Message-ID:  <Pine.UW2.3.95.970122170128.4605D-100000@cedb>
In-Reply-To: <199701230036.SAA01696@main.intcomm.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 22 Jan 1997, Jim Bentley wrote:
> When attempting to execute a foreach command in csh script the variables are
> not set correctly.

Number 1, don't script in csh.  Every Unix seems to have its own set
of csh bugs which are incompatable.  Use sh, ksh , perl, tcl ..... :)

> foreach user (cat /usr/local/www/file.lst)
> 
> The user variable is set equal to "cat /usr/local/www/file.lst" instead of
> the the data in the lines of the file.

Actually $user gets set to "cat" and later to "/usr/local/www/file.lst"

You need to surround the command with back ticks to have it executed.

	foreach user (`cat /usr/local/www/file.lst`)

does what you want.

But don't do it, use sh, ksh perl ..... 

Dan
-- 
 Dan Busarow                                                  714 443 4172
 DPC Systems / Beach.Net                                    dan@dpcsys.com
 Dana Point, California  83 09 EF 59 E0 11 89 B4   8D 09 DB FD E1 DD 0C 82




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.UW2.3.95.970122170128.4605D-100000>