#if()
DESCRIPTION
returns one number, if a logical expression is TRUE;
else another number, if the logical expression is FALSE
or:
returns a number, if a logical expression is TRUE;
else the special numerical value NIL, if the logical expression is false
SYNOPSIS
#if(x,n1,n2)
or:
#if(x,n)
ARGUMENTS
x - a logical condition, or conditional expression
n1 - a number, or numerical expression
n2 - a number, or numerical expression
or:
x - a logical condition, or conditional expression
n - a number, or numerical expression
EXAMPLES
rule // set $gname, stripping off "+" or "-", if present
set $gname = $substr($group,#if(#nis,2,1))
rule // get log file size, in lines for text files, and KB for
// binary files
set #size = #if(#binary, #filesize($name)/=KB,
#val($command("=wc -l $name | =awk '{print \$1}'")))
rule // if it's been more than #hrs hours since the last piktd_log
// entry, piktd is not logging, hence appears to be hung/dead;
do #split($time, ":")
set #t = #datevalue(#yrnow -
#if(#monnow == 1 && $mon eq "Dec", 1, 0),
#monthnumber($mon), #date)
+ #timevalue(#val($[1]), #val($[2]), #val($[3]))
if #timenow - #t > #hrs*60*60
output mail "piktd appears to be hung/dead on $sys"
endif
SEE ALSO
#and()
#or()
#true()
#false()
#not()
Numerical Functions
String Functions