Need to add [] around conditionals in if statements

Comment on Asterisk tips openclose.agi
zwi
Joined: Thu 10 of Jun, 2004

Need to add [] around conditionals in if statements

Posted:Thu 10 of Jun, 2004 (18:56 UTC)
In order to make this work with my Red Hat 8 system (and adhere to standard bourne shell) I had to enclose the conditionals in [] like:

if [ "$DAY" = "Sun" -a \
"$TIMENOW" -gt "0900" -a \
"$TIMENOW" -lt "1300" ]]
then
STATUS=open
fi

If your system always seems "closed" see if this is your problem. The best way to test this is just to run it on the command line and see if the script gives you errors.

Actually it looks like tiki strips out square brackets when posting so that may be the original problem. I guess when posting code to this wiki use [[ and ]]]