Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

csh foreach/end; if/endif problem

386 views
Skip to first unread message

Larry Pisani

unread,
Feb 7, 1996, 3:00:00 AM2/7/96
to
Hi there, folks... I hope someone can help me out.
I keep getting an error from this csh script. The script is fairly
straight-forward, it checks to see if there's a difference between 2
files (/etc/passwd & /master/etc/passwd). If so, it runs a script
(/master/scripts/update_nis_pw.sh), then copiesone file to another.
It then checks each host on the network (listed in file: node_list) to
see if it's running NIS, if not, it copies the master passwd file to
the host's /etc/passwd, otherwise it continues.

When I commment out the 'if ($status != 0)then' and it's relative 'endif'
line, the script runs fine. (Of course, it doesn't skip the nodes running
NIS) Any ideas would be appreciated, this is driving me nuts! :)

Thanks in advance.

Larry Pisani

========================================================================
This is the script:
-------------------

#!/bin/csh
#
diff /etc/passwd /master/etc/passwd >/tmp/up.pass
grep bin /tmp/up.pass >/dev/null
if ($status == 0)then
/master/scripts/update_nis_pw.sh
cp /etc/passwd /master/etc/passwd
foreach node (`cat /master/scripts/node_list`)
remsh $node ypwhich | grep 'srv'
if ($status != 0)then
rcp /master/etc/passwd $node\:/etc/passwd
endif
end
endif
rm /tmp/up.pass

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=========================================================================
error message:
--------------

end: Not in while/foreach.

Marcel Meijn

unread,
Feb 8, 1996, 3:00:00 AM2/8/96
to
Larry Pisani wrote:
-/-

> cp /etc/passwd /master/etc/passwd
> foreach node (`cat /master/scripts/node_list`)
> remsh $node ypwhich | grep 'srv'
My idea is that $node may contain a reserved keyword triggering
while/foreach. Try to use quotes:

remsh "$node" ypwhich | grep 'srv'

> if ($status != 0)then
> rcp /master/etc/passwd $node\:/etc/passwd
> endif
> end
> endif
> rm /tmp/up.pass

-/-


> error message:
> --------------
>
> end: Not in while/foreach.


Good luck,
Marcel
--
____ __ . . __
| | | |_ |_| | | mailto:me...@nlr.nl tel: +31 20 5113495
| | | |__ _| | | National Aerospace Laboratory NLR fax: +31 20 5113210

0 new messages