[Gloucs] scripting

Paul Broadhead gloucs at mailman.lug.org.uk
Thu May 29 23:18:01 2003


Richard Mellersh <richard@the-sett.nildram.co.uk> wrote:

> Can anyone help?
> 
> I'm still trying to sort out some old stuff that never worked on older 
> systems.  There is something wrong with line 4 inside the [brackets] - 
> expects a "unary operator".
> 
> #! /bin/bash
> typeset -i num
> num=ifconfig | grep eth1 | wc -l
> if [$num -eq 0] ; then
> 	ifconfig eth1 192.168.1.200 up
> 	route delete -net 192.168.1.0/24 eth1
> 	route add -host 192.168.1.201 eth1
> fi
> 
> Any ideas?

Try putting some space between the [] and the contents, i.e.

if [ $num -eq 0 ] ; then
....

Paul