Subject: variables in csh
To: None <netbsd-help@netbsd.org>
From: Gan Uesli Starling <oinkfreebiker@att.net>
List: netbsd-help
Date: 10/14/2001 20:27:17
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

...so that I can call the script and it will kill one or more results from...

# ps | grep ppp-up
527 E2 I 0:00.01 /bin/sh ./ppp-up-gus

I don't really need the script. It was just a hack to save some typing and 
eye-balling of ps when I am experimenting. I wanted to write it because I see
that the PID stays alive when I do /etc/ppp/ppp-down from the NetBSD Guide.
The pppd does go down, but PS still reports a PID. So I thought I should kill 
any such PID.

The process below is the most infuriating when it doesn't go down on 
/etc/ppp/ppp-down...

tail -f -n 0 /var/log/messages

...because I get multiple messages on every ppp-up re-trial. I have to stop, 
do ps, then scan and kill them one-by-one. It's a drag...

Like I said, the script is not the big thing. But clearly I don't understand 
variables in csh. Why does it work on the command line but not in a script?

Regards,

Gan