[Gloucs] scripting

Paul Broadhead gloucs at mailman.lug.org.uk
Thu May 29 23:54:00 2003


Steve Searle <mail@stevesearle.com> wrote:

> Around 10:58pm on Thursday, May 29, 2003 (UK time), Richard Mellersh scrawled:
> 
> > 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
> 
> I don't think this line is returning an integer.  After adding spaces
> after/before the [s, I got the unary operator message.  Setting num to 0
> removes the error message, and echoing num after it has been set
> displays "<whitespace>0".

Should the line

num=ifconfig | grep eth1 | wc -l

be

num=$(ifconfig | grep eth1 | wc -l)

or

num=`ifconfig | grep eth1 | wc -l`

to actually execute the command.

Could be wrong, its past my bedtime....

Paul