Sponsored Content
Top Forums Shell Programming and Scripting syntax error in shell test: unknown operator Post 302301324 by shellscripter on Thursday 26th of March 2009 01:45:12 PM
Old 03-26-2009
Error 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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

:0: unknown test operator

I have gotten the script up to this point and it works fine a system but when i copy it to another unix server running solaris 9 as the original one , its gives an error './mon_fs.sh: 0: unknown test operator' . (see script bellow) can the Gurus see to this as i am just a beginner with... (2 Replies)
Discussion started by: ibroxy
2 Replies

2. UNIX for Advanced & Expert Users

unknown test operator

Hi, I have the following shell script : Nbr_BD_Link=0 Nbr_BD_Link=` sqlplus sysadm/${PSWD}@${DB_Name} << EOF | tail -4 | head -1 2>/dev/null set head off feedback off ; select count(*) from dba_db_links ; exit ; EOF ` echo ${Nbr_BD_Link} if ; then ... (4 Replies)
Discussion started by: big123456
4 Replies

3. Shell Programming and Scripting

test: unknown operator status

hi I get test: unknown operator status if then echo "OK." return 0 else echo "not ok" 2>&1 exit -1 fi I tried to change "A" with 'A' --> same error I tried to change if , I am getting: (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

4. Shell Programming and Scripting

if returns "unknown test operator"

Greetings, using ksh on Solaris, I am trying to identify the current version of a package installed on multiple servers using if statement in a precursor to upgrading. I have searched the forums and have found many hits, reviewed 3 pages and have tried the different variations noted there. Also... (3 Replies)
Discussion started by: 22blaze
3 Replies

5. Shell Programming and Scripting

unknown test operator

hi all, i am using the below command in my script if ; then This statement is causing the problme "ScriptName.ksh: XXX-XXX: unknown test operator" could you please suggest me , how can i avoid these messages. Singhal (7 Replies)
Discussion started by: singhald
7 Replies

6. Programming

Help Unknown Syntax Error

Please excuse me if this is an easy fix, for I am new to Unix and C '/problem1.c: line2: syntax error near unexpected token ` '/problem1.c: line2: `main() and for one program it has : command not found2: (above the syntax error) As mentioned this is in C not C++, I have complied all... (3 Replies)
Discussion started by: apolo93
3 Replies

7. Shell Programming and Scripting

Unknown test operator

Hi , Os - Solaris Shell - Ksh I am getting below error in if condition + id + ./om_wf_complete.sh: gid=4081(Infadmn): unknown test operator + exit 1 if ; then touch /home/odwt/1.0.0/out/oworkflow.dat chmod 777 /home/odwt/1.0.0/out/oworkflow.dat elif ; then touch... (8 Replies)
Discussion started by: nag_sathi
8 Replies

8. Shell Programming and Scripting

Unknown test operator

O/S solaris 9 shell ksh if then chk_op="WARNING...reboot within the last 24hrs, restarted at `who -r | awk '{print $4$5"@"$6}'`" ; else if ; then last_reboot1=`who -b | awk '{print $4" "$5" "$6}'` last_reboot2='..OK..'`uptime | awk '{print$3" "$4}'` ... (4 Replies)
Discussion started by: squrcles
4 Replies

9. Shell Programming and Scripting

Getting syntax error with awk ternary operator

split($7,a," "); date = a; time = a split(date,d,"/"); month = sprintf("%02d",d); day = sprintf("%02d",d); year = 2000 + d % 100 split(time,t,":"); hour=t; min=t hour >= 12? { hour=hour-12; amPm=" PM" } : amPM=" AM" hour == 0? hour=12 time=sprintf("%02d",hour)":"sprintf("%02d",min)amPm ... (4 Replies)
Discussion started by: Michael Stora
4 Replies

10. Shell Programming and Scripting

Getting unknown operator error while using a function

Hi, I wrote a function for the first time and not able to get the desired result. I have requirement to execute 10 queries. For this i wrote a function like below. function Command { typeset var SOL; if ; then CONNECTION="${CONNECTION} -e -time"; else SOL="`nzsql ${CONNECTION} -c... (8 Replies)
Discussion started by: Samah
8 Replies
VERSION_COMPARE(3)							 1							VERSION_COMPARE(3)

version_compare - Compares two ";PHP-standardized" version number strings

SYNOPSIS
mixed version_compare (string $version1, string $version2, [string $operator]) DESCRIPTION
version_compare(3) compares two "PHP-standardized" version number strings. The function first replaces _, - and + with a dot . in the version strings and also inserts dots . before and after any non number so that for example '4.3.2RC1' becomes '4.3.2.RC.1'. Then it compares the parts starting from left to right. If a part contains special version strings these are handled in the following order: any string not found in this list < dev < alpha = a < beta = b < RC = rc < # < pl = p. This way not only versions with different levels like '4.1' and '4.1.2' can be compared but also any PHP specific version containing devel- opment state. PARAMETERS
o $version1 - First version number. o $version2 - Second version number. o $operator - If the third optional $operator argument is specified, test for a particular relationship. The possible operators are: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne respectively. This parameter is case-sensitive, values should be lowercase. RETURN VALUES
By default, version_compare(3) returns -1 if the first version is lower than the second, 0 if they are equal, and 1 if the second is lower. When using the optional $operator argument, the function will return TRUE if the relationship is the one specified by the operator, FALSE otherwise. EXAMPLES
The examples below use the PHP_VERSION constant, because it contains the value of the PHP version that is executing the code. Example #1 version_compare(3) examples <?php if (version_compare(PHP_VERSION, '6.0.0') >= 0) { echo 'I am at least PHP version 6.0.0, my version: ' . PHP_VERSION . " "; } if (version_compare(PHP_VERSION, '5.3.0') >= 0) { echo 'I am at least PHP version 5.3.0, my version: ' . PHP_VERSION . " "; } if (version_compare(PHP_VERSION, '5.0.0', '>=')) { echo 'I am using PHP 5, my version: ' . PHP_VERSION . " "; } if (version_compare(PHP_VERSION, '5.0.0', '<')) { echo 'I am using PHP 4, my version: ' . PHP_VERSION . " "; } ?> NOTES
Note The PHP_VERSION constant holds current PHP version. Note Note that pre-release versions, such as 5.3.0-dev, are considered lower than their final release counterparts (like 5.3.0). Note Special version strings such as alpha and beta are case sensitive. Version strings from arbitrary sources that do not adhere to the PHP standard may need to be lowercased via strtolower(3) before calling version_compare(3). SEE ALSO
phpversion(3), php_uname(3), function_exists(3). PHP Documentation Group VERSION_COMPARE(3)
All times are GMT -4. The time now is 07:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy