Problems doing 3 embedded if statements to get true/false for relevanc

(imported topic written by SystemAdmin)

I’m trying the following statement to check our if our ssh version needs upgrade across multiple operating systems.

if (computer name does not contain “glb” and name of operating system contains “SunOS” and exist pkginfo “OBSDssh” of pkgdb and (version of pkginfo “OBSDssh” of pkgdb as trimmed string) as version < " as version) then “true” else if (exist file “/opt/sni/unix/etc/sshversion” and not exist line whose ( it contains “OpenSSH_5.9” ) of file “/opt/sni/unix/etc/sshversion”) then “true” else if (name of operating system contains “Linux” and (version of package “obsdssh” of rpm != “5.9p1-rdht1” and version of package “obsdssh” of rpm != “5.9p1-suse1”)) then "true else “false” else “false” else “false”

What am I doing wrong… Each of the 3 If’s do work correctly on there individual operating systems.

(imported comment written by NoahSalzman)

Do you use the debugger, it’s very helpful. Just use the “Indent Relevance” button and you can (usually) see where the problem is. Didn’t try this on a linux box, but I believe the syntax errors are gone.

if (computer name does not contain “glb” and name of operating system contains “SunOS” and exist pkginfo “OBSDssh” of pkgdb and (version of pkginfo “OBSDssh” of pkgdb as trimmed string) as version < " as version) then “true” else if (exist file “/opt/sni/unix/etc/sshversion” and not exist line whose (it contains “OpenSSH_5.9”) of file “/opt/sni/unix/etc/sshversion”) then “true” else if (name of operating system contains “Linux” and (version of package “obsdssh” of rpm != “5.9p1-rdht1” and version of package “obsdssh” of rpm != “5.9p1-suse1”)) then “true” else “false”

if ( computer name does not contain 
"glb" and name of operating system contains 
"SunOS" and exist pkginfo 
"OBSDssh" of pkgdb and ( version of pkginfo 
"OBSDssh" of pkgdb as trimmed string ) as version < 
"5.9" as version ) then 
"true" 

else 

if ( exist file 
"/opt/sni/unix/etc/sshversion" and not exist line whose ( it contains 
"OpenSSH_5.9" ) of file 
"/opt/sni/unix/etc/sshversion" ) then 
"true" 

else 

if ( name of operating system contains 
"Linux" and ( version of 

package 
"obsdssh" of rpm != 
"5.9p1-rdht1" and version of 

package 
"obsdssh" of rpm != 
"5.9p1-suse1" ) ) then 
"true" 

else 
"false"

(imported comment written by NoahSalzman)

Also, note that your structure:

if
   exists "something" 
 then
   true 
 else
   if
 exists "in the way" 
   then
 true 
   else
 if
   exists "she moves"
 then
   true 
 else
   false

Is syntactically equivalent to:

exists "something" 
OR
 exists "in the way" 
OR
 exists "she moves"

(imported comment written by SystemAdmin)

Your update does report “True” for the first if , but all others report

(imported comment written by jeremylam)

All inspectors are not available on all operating systems, and relevance evaluation does not do short-circuit evaluation when it cannot parse specific inspectors, and returns the undefined error.

A statement like:

name of operating system contains "Win" and <windows specific inspectors>

Will only work on Windows systems - it will return an error on non-Windows systems even though we both can see the first statement will return false.

Your original statement is similar to:

name of operating system contains "SunOS" and <solaris specific inspector>
 OR
 name of operating system contains "Linux" and <linux specific inspector>

Which will not work on any system.

You have to split it with if/then/else

if (name of operating system contains "SunOS") then
<solaris specific  inspectors>
else
if (name of operating system contains "Linux") then
<linux specific  inspectors>
else
false

(imported comment written by SystemAdmin)

Getting different results once this long statement is added to a fixlet, but works fine in an analysis property or in QnA debugger

(1) In an analysis or QnA debugger:

Q: if ( computer name does not contain “glb” and name of operating system contains “SunOS” ) then if ( exist pkginfo “OBSDssh” of pkgdb and ( version of pkginfo “OBSDssh” of pkgdb as trimmed string ) as version < " as version ) then “true” else “false” else if (name of operating system contains “AIX”) then if ( exist file “/opt/sni/unix/etc/sshversion” and following text of first “OpenSSH_” of preceding text of first “p1” of ( it as string) of line 1 of file “/opt/sni/unix/etc/sshversion” < “5.9” ) then “true” else “false” else if ( name of operating system contains “Linux”) then if (preceding text of first “p1” of ( it as string) of version of package “obsdssh” of rpm <“5.9”) then “true” else “false” else “false”

A: false

T: 28841

(2) Taken from relevance statement after it’s saved in a fixlet

Q: (version of client >= “6.0.0.0”) AND (exists true whose (if true then (if ( computer name does not contain “glb” and name of operating system contains “SunOS” ) then if ( exist pkginfo “OBSDssh” of pkgdb and ( version of pkginfo “OBSDssh” of pkgdb as trimmed string ) as version < " as version ) then “true” else “false” else if (name of operating system contains “AIX”) then if ( exist file “/opt/sni/unix/etc/sshversion” and following text of first “OpenSSH_” of preceding text of first “p1” of ( it as string) of line 1 of file “/opt/sni/unix/etc/sshversion” < “5.9” ) then “true” else “false” else if ( name of operating system contains “Linux”) then if (preceding text of first “p1” of ( it as string) of version of package “obsdssh” of rpm <“5.9”) then “true” else “false” else “false”) else false))

E: Incompatible types.

If the prefix code added of :

(version of client >= “6.0.0.0”) AND (exists true whose (if true then (

and suffix of:

else false))

Messing me up??? any idea how to get around this condition???

(imported comment written by SystemAdmin)

I figured it out… I just had to remove the " " around the true/false