Subject: Re: variables in csh
To: Gan Uesli Starling <oinkfreebiker@att.net>
From: Anders Dinsen <anders@dinsen.net>
List: netbsd-help
Date: 10/15/2001 08:48:22
On Sun, 14 Oct 2001, Gan Uesli Starling wrote:

> I'd like to set a variable in a shell script. I can do it on the command line
> but in a script it fails.
>
> On the command line...
>
> set foo = `ps | grep ppp-up | cut -d ' ' -f1 | tr '\n' ' ' `
>
> ...so that later I can...
>
> echo $foo
> kill $foo
>
> And in the script...
>
> foo = `ps | grep ppp-up | cut -d ' ' -f1 | tr '\n' ' ' `
> if ( $foo != '' ); then
>   kill $foo
> fi

Your variable is not automatically transferred from the shell (command
line) environment to the script, unless it's an enviroment variable set
with setenv (export'ed in sh).

That might also be troubling you.

Unless you run your script by

% source myscript

because then it's run in the same instance of csh.

-- 
Anders Dinsen
anders@dinsen.net
http://dinsen.net/anders/