syntax error in shell test: unknown operator

Hi All,

can some one figure out the syntax issue here. How to overcome this?

#!/bin/sh

$ HFR_MAIL=NO
$ PRP_MAIL=NO
$ MC_MAIL=NO
$ if [ [ "$HFR_MAIL" = "NO" ] && [ "$PRP_MAIL" = "NO" ] && [ "$MC_MAIL" = "NO" ] ]; then
> echo "NO "
> else
> echo "YES"
> fi
test: unknown operator NO
$ if [ [ "$HFR_MAIL" -eq "NO" ] && [ "$PRP_MAIL" -eq "NO" ] && [ "$MC_MAIL" -eq "NO" ] ]; then
> echo "NO"
> else
> echo "YES"
> fi
test: unknown operator NO
$

Thanks,
Parkkavan

is it a ksh or bash?? if its ksh no need of [ [ use only [ and use -a instead of &&

if [ "$HFR_MAIL" = "NO" -a ...... -a ......] ; then

Hi,
Does Your script actually contain $ and > ?
that is not correct syntax, remove them and try again

Try this:

HFR_MAIL=NO
PRP_MAIL=NO
MC_MAIL=NO
if [[ "$HFR_MAIL" == "NO" && "$PRP_MAIL" == "NO" && "$MC_MAIL" == "NO" ]]; then
   echo "NO "
else
   echo "YES"
fi

regards,
Arun.

Hi All,

Thanks for your quick response which helps me a lot. I have tried using BASH shell

if [[ "$HFR_MAIL" == "NO" && "$PRP_MAIL" == "NO" && "$MC_MAIL" == "NO" ]]; then

It worked fine.

Regards,
Parkkavan