[PLUG] Need Explanation of BASH Script Error

Russell Johnson russ at dimstar.net
Sat Feb 18 20:05:52 UTC 2012


On Feb 18, 2012, at 9:01 AM, Rich Shepard wrote:

>   OK. CURRENTIP does exist. Even if curl could not connect to the URL why
> generate an error message about expecting a unary operator for the !=?

The error doesn't happen until the 'if' statement. The curl command fails silently, leaving $NEWIP unset because there was no return value. 

When the variable is unset then you are asking if something is not equal to an unset variable. This causes the error because it doesn't handle that case. It's like saying "2 != ", and bash goes, "huh? 2 is not equal to WHAT???" It's missing a required operator for that operation.

Russell Johnson
russ at dimstar.net






More information about the PLUG mailing list