[plug] problem found in "if" statement
Jon Miller
jlmiller at mmtnetworks.com.au
Wed Aug 27 14:35:49 WST 2003
#!/bin/sh
Jon L. Miller, MCNE, CNS
Director/Sr Systems Consultant
MMT Networks Pty Ltd
http://www.mmtnetworks.com.au
"I don't know the key to success, but the key to failure
is trying to please everybody." -Bill Cosby
>>> bernie at innovative.iinet.net.au 1:26:52 PM 27/08/2003 >>>
On Wed, Aug 27, 2003 at 09:13:12AM +0800, Jon Miller wrote:
> I've found a problem in an "if" statement and cannot find a fix. The statement is
> if [ "$vMLSTAT" >= 0 ]; then
> .....
That looks like a syntax error to me; but I don't know which shell
you're using.
> .....
>
> fi
Try "-ge" instead of ">="
> I'm getting a unary operator expected. I've tried also the
> following and got a error message stating that [ : : integer
> expression expected
> if [ "$vMLSTAT" -lt 0 ]; then
> ......
> ......
> fi
That can happen if the variable isn't set to anything.
A "hack" around that problem is to prefix the "number" with a
literal zero e.g.
if [ 0"$vMLSTAT" -lt 0 ]; then
which works for positive numbers only!
Korn (and Bash, IIUC) shells allow type definitions for variables.
--
/"\ Bernd Felsche - Innovative Reckoning, Perth, Western Australia
\ / ASCII ribbon campaign | I'm a .signature virus!
X against HTML mail | Copy me into your ~/.signature
/ \ and postings | to help me spread!
More information about the plug
mailing list