Predefined Functions
Any ClassAd expression may utilize predefined functions. Function names are case insensitive. Parameters to functions and a return value from a function may be typed (as given) or not. Nested or recursive function calls are allowed.
Here are descriptions of each of these predefined functions. The
possible types are the same as itemized in
ClassAd Syntax. Where the type may
be any of these literal types, it is called out as AnyType. Where the type is
Integer, but only returns the value 1 or 0 (implying True
or
False
), it is called out as Boolean. The format of each function is
given as
ReturnType FunctionName(ParameterType parameter1, ParameterType parameter2, ...)
Optional parameters are given within square brackets.
AnyType eval(AnyType Expr)
¶Evaluates
Expr
as a string and then returns the result of evaluating the contents of the string as a ClassAd expression. This is useful when referring to an attribute such asslotX_State
whereX
, the desired slot number is an expression, such asSlotID+10
. In such a case, if attribute SlotID is 5, the value of the attributeslot15_State
can be referenced using the expressioneval(strcat("slot", SlotID+10,"_State"))
. Function strcat() calls function string() on the second parameter, which evaluates the expression, and then converts the integer result 15 to the string"15"
. The concatenated string returned by strcat() is"slot15_State"
, and this string is then evaluated.Note that referring to attributes of a job from within the string passed to eval() in the
Requirements
orRank
expressions could cause inaccuracies in HTCondor’s automatic auto-clustering of jobs into equivalent groups for matchmaking purposes. This is because HTCondor needs to determine which ClassAd attributes are significant for matchmaking purposes, and indirect references from within the string passed to eval() will not be counted.String unparse(Attribute attr)
¶This function looks up the value of the provided attribute and returns the unparsed version as a string. The attribute’s value is not evaluated. If the attribute’s value is
x + 3
, then the function would return the string"x + 3"
. If the provided attribute cannot be found, an empty string is returned.This function returns
ERROR
if other than exactly 1 argument is given or the argument is not an attribute reference.String unresolved(Attribute attr)
¶This function returns the external attribute references and unresolved attribute references of the expression that is the value of the provided attribute. If the provided attribute cannot be found, then
undefined
is returned.For example, in a typical job ClassAd if the
Requirements
expression has the valueOpSys == "LINUX" && TARGET.Arch == "ARM" && Cpus >= RequestCpus
, thenunresolved(Requirements)
will return"Arch,Cpus,OpSys"
because those will not be attributes of the job ClassAd.Boolean unresolved(Attribute attr, String pattern)
¶This function returns
True
when at least one of the external or unresolved attribute references of the expression that is the value of the provided attribute matches the given Perl regular expression pattern. If none of the references match the pattern, thenFalse
is returned. If the provided attribute cannot be found, thenundefined
is returned.For example, in a typical job ClassAd if the
Requirements
expression has the valueOpSys == "LINUX" && Arch == "ARM"
, thenunresolved(Requirements, "^OpSys")
will returnTrue
, andunresolved(Requirements, "OpSys.+")
will returnFalse
.The intended use of this function is to make it easier to apply a submit transform to a job only when the job does not already reference a certain attribute. For instance
JOB_TRANSFORM_DefPlatform @=end # Apply this transform only when the job requirements does not reference OpSysAndver or OpSysName REQUIREMENTS ! unresolved(Requirements, "OpSys.+") # Add a clause to the job requirements to match only CentOs7 machines SET Requirements $(MY.Requirements) && OpSysAndVer == "CentOS7" @end
AnyType ifThenElse(AnyType IfExpr,AnyType ThenExpr, AnyType ElseExpr)
¶A conditional expression is described by
IfExpr
. The following defines return values, whenIfExpr
evaluates toTrue
. Evaluate and return the value as given byThenExpr
.False
. Evaluate and return the value as given byElseExpr
.UNDEFINED
. Return the valueUNDEFINED
.ERROR
. Return the valueERROR
.0.0
. Evaluate, and return the value as given byElseExpr
.non-
0.0
Real values. Evaluate, and return the value as given byThenExpr
.
Where
IfExpr
evaluates to give a value of typeString
, the function returns the valueERROR
. The implementation uses lazy evaluation, so expressions are only evaluated as defined.This function returns
ERROR
if other than exactly 3 arguments are given.Boolean isUndefined(AnyType Expr)
¶Returns
True
, ifExpr
evaluates toUNDEFINED
. ReturnsFalse
in all other cases.This function returns
ERROR
if other than exactly 1 argument is given.Boolean isError(AnyType Expr)
¶Returns
True
, ifExpr
evaluates toERROR
. ReturnsFalse
in all other cases.This function returns
ERROR
if other than exactly 1 argument is given.Boolean isString(AnyType Expr)
¶Returns
True
, if the evaluation ofExpr
gives a value of typeString
. ReturnsFalse
in all other cases.This function returns
ERROR
if other than exactly 1 argument is given.Boolean isInteger(AnyType Expr)
¶Returns
True
, if the evaluation ofExpr
gives a value of typeInteger
. ReturnsFalse
in all other cases.This function returns
ERROR
if other than exactly 1 argument is given.Boolean isReal(AnyType Expr)
¶Returns
True
, if the evaluation ofExpr
gives a value of typeReal
. ReturnsFalse
in all other cases.This function returns
ERROR
if other than exactly 1 argument is given.Boolean isList(AnyType Expr)
¶Returns
True
, if the evaluation ofExpr
gives a value of typeList
. ReturnsFalse
in all other cases.This function returns
ERROR
if other than exactly 1 argument is given.Boolean isClassAd(AnyType Expr)
¶Returns
True
, if the evaluation ofExpr
gives a value of typeClassAd
. ReturnsFalse
in all other cases.This function returns
ERROR
if other than exactly 1 argument is given.Boolean isBoolean(AnyType Expr)
¶Returns
True
, if the evaluation ofExpr
gives the integer value 0 or 1. ReturnsFalse
in all other cases.This function returns
ERROR
if other than exactly 1 argument is given.Boolean isAbstime(AnyType Expr)
¶Returns
True
, if the evaluation ofExpr
returns an abstime type. ReturnsFalse
in all other cases.This function returns
ERROR
if other than exactly 1 argument is given.Boolean isReltime(AnyType Expr)
¶Returns
True
, if the evaluation ofExpr
returns an relative time type. ReturnsFalse
in all other cases.This function returns
ERROR
if other than exactly 1 argument is given.Boolean member(AnyType m, ListType l)
¶Returns error if m does not evalute to a scalar, or l does not evaluate to a list. Otherwise the elements of l are evaluted in order, and if an element is equal to m in the sense of
==
the result of the function isTrue
. Otherwise the function returns false.Boolean anyCompare(string op, list l, AnyType t)
¶Returns error if op does not evalute to one of
<
,<=
,==
,>
,>=
,!-
,is
orisnt
. Returns error if l isn’t a list, or t isn’t a scalar Otherwise the elements of l are evaluted and compared to t using the corresponding operator defined by op. If any of the members of l evaluate to true, the result isTrue
. Otherwise the function returnsFalse
.Boolean allCompare(string op, list l, AnyType t)
¶Returns error if op does not evalute to one of
<
,<=
,==
,>
,>=
,!-
,is
orisnt
. Returns error if l isn’t a list, or t isn’t a scalar Otherwise the elements of l are evaluted and compared to t using the corresponding operator defined by op. If all of the members of l evaluate to true, the result isTrue
. Otherwise the function returnsFalse
.Boolean identicalMember(AnyType m, ListType l)
¶Returns error if m does not evalute to a scalar, or l does not evaluate to a list. Otherwise the elements of l are evaluted in order, and if an element is equal to m in the sense of
=?=
the result of the function isTrue
. Otherwise the function returns false.Integer int(AnyType Expr)
¶Returns the integer value as defined by
Expr
. Where the type of the evaluatedExpr
isReal
, the value is truncated (round towards zero) to an integer. Where the type of the evaluatedExpr
isString
, the string is converted to an integer using a C-like atoi() function. When this result is not an integer,ERROR
is returned. Where the evaluatedExpr
isERROR
orUNDEFINED
,ERROR
is returned.This function returns
ERROR
if other than exactly 1 argument is given.Real real(AnyType Expr)
¶Returns the real value as defined by
Expr
. Where the type of the evaluatedExpr
isInteger
, the return value is the converted integer. Where the type of the evaluatedExpr
isString
, the string is converted to a real value using a C-like atof() function. When this result is not a real,ERROR
is returned. Where the evaluatedExpr
isERROR
orUNDEFINED
,ERROR
is returned.This function returns
ERROR
if other than exactly 1 argument is given.String string(AnyType Expr)
¶Returns the string that results from the evaluation of
Expr
. Converts a non-string value to a string. Where the evaluatedExpr
isERROR
orUNDEFINED
,ERROR
is returned.This function returns
ERROR
if other than exactly 1 argument is given.Bool bool(AnyType Expr)
¶Returns the boolean that results from the evaluation of
Expr
. Converts a non-boolean value to a bool. A string expression that evaluates to the string “true” yields true, and “false” returnsThis function returns
ERROR
if other than exactly 1 argument is given.AbsTime absTime(AnyType t [, int z])
¶Creates an AbsTime value corresponding to time t an time-zone offset z. If t is a String, then z must be omitted, and t is parsed as a specification as follows.
The operand t is parsed as a specification of an instant in time (date and time). This function accepts the canonical native representation of AbsTime values, but minor variations in format are allowed. The default format is yyyy-mm-ddThh:mm:sszzzzz where zzzzz is a time zone in the format +hh:mm or -hh:mm
If t and z are both omitted, the result is an AbsTime value representing the time and place where the function call is evaluated. Otherwise, t is converted to a Real by the function “real”, and treated as a number of seconds from the epoch, Midnight January 1, 1970 UTC. If z is specified, it is treated as a number of seconds east of Greenwich. Otherwise, the offset is calculated from t according to the local rules for the place where the function is evaluated.
RelTime relTime(AnyType t)
¶If the operand t is a String, it is parsed as a specification of a time interval. This function accepts the canonical native representation of RelTime values, but minor variations in format are allowed.
Otherwise, t is converted to a Real by the function real, and treated as a number of seconds. The default string format is [-]days+hh:mm:ss.fff, where leading components and the fraction .fff are omitted if they are zero. In the default syntax, days is a sequence of digits starting with a non-zero digit, hh, mm, and ss are strings of exactly two digits (padded on the left with zeros if necessary) with values less than 24, 60, and 60, respectively and fff is a string of exactly three digits.
Integer floor(AnyType Expr)
¶Returns the integer that results from the evaluation of
Expr
, where the type of the evaluatedExpr
isInteger
. Where the type of the evaluatedExpr
is notInteger
, functionreal(Expr)
is called. Its return value is then used to return the largest magnitude integer that is not larger than the returned value. Wherereal(Expr)
returnsERROR
orUNDEFINED
,ERROR
is returned.This function returns
ERROR
if other than exactly 1 argument is given.Integer ceiling(AnyType Expr)
¶Returns the integer that results from the evaluation of
Expr
, where the type of the evaluatedExpr
isInteger
. Where the type of the evaluatedExpr
is notInteger
, functionreal(Expr)
is called. Its return value is then used to return the smallest magnitude integer that is not less than the returned value. Wherereal(Expr)
returnsERROR
orUNDEFINED
,ERROR
is returned.This function returns
ERROR
if other than exactly 1 argument is given.Integer pow(Integer base, Integer exponent)
¶ ORReal pow(Integer base, Integer exponent)
¶ ORReal pow(Real base, Real exponent)
¶Calculates
base
raised to the power ofexponent
. Ifexponent
is an integer value greater than or equal to 0, andbase
is an integer, then an integer value is returned. Ifexponent
is an integer value less than 0, or if eitherbase
orexponent
is a real, then a real value is returned. An invocation withexponent=0
orexponent=0.0
, for any value ofbase
, including 0 or 0.0, returns the value 1 or 1.0, type appropriate.Integer quantize(AnyType a, Integer b)
¶ ORReal quantize(AnyType a, Real b)
¶ ORAnyType quantize(AnyType a, AnyType list b)
¶quantize()
computes the quotient ofa/b
, in order to further compute `` ceiling(quotient) * b``. This computes and returns an integral multiple ofb
that is at least as large asa
. So, whenb >= a
, the return value will beb
. The return type is the same as that ofb
, whereb
is an Integer or Real.When
b
is a list,quantize()
returns the first value in the list that is greater than or equal toa
. When no value in the list is greater than or equal toa
, this computes and returns an integral multiple of the last member in the list that is at least as large asa
.This function returns
ERROR
ifa
orb
, or a member of the list that must be considered is not an Integer or Real.Here are examples:
8 = quantize(3, 8) 4 = quantize(3, 2) 0 = quantize(0, 4) 6.8 = quantize(1.5, 6.8) 7.2 = quantize(6.8, 1.2) 10.2 = quantize(10, 5.1) 4 = quantize(0, {4}) 2 = quantize(2, {1, 2, "A"}) 3.0 = quantize(3, {1, 2, 0.5}) 3.0 = quantize(2.7, {1, 2, 0.5}) ERROR = quantize(3, {1, 2, "A"})
Integer round(AnyType Expr)
¶Returns the integer that results from the evaluation of
Expr
, where the type of the evaluatedExpr
isInteger
. Where the type of the evaluatedExpr
is notInteger
, functionreal(Expr)
is called. Its return value is then used to return the integer that results from a round-to-nearest rounding method. The nearest integer value to the return value is returned, except in the case of the value at the exact midpoint between two integer values. In this case, the even valued integer is returned. Wherereal(Expr)
returnsERROR
orUNDEFINED
, or the integer value does not fit into 32 bits,ERROR
is returned.This function returns
ERROR
if other than exactly 1 argument is given.Integer random([ AnyType Expr ])
¶Where the optional argument
Expr
evaluates to typeInteger
or typeReal
(and calledx
), the return value is the integer or realr
randomly chosen from the interval0 <= r < x
. With no argument, the return value is chosen withrandom(1.0)
. ReturnsERROR
in all other cases.This function returns
ERROR
if greater than 1 argument is given.Number sum([ List l ])
¶The elements of l are evaluated, producing a list l of values. Undefined values are removed. If the resulting l is composed only of numbers, the result is the sum of the values, as a Real if any value is Real, and as an Integer otherwise. If the list is empty, the result is 0. If the list has only Undefined values, the result is
UNDEFINED
. In other cases, the result isERROR
.This function returns
ERROR
if greater than 1 argument is given.Number avg([ List l ])
¶The elements of l are evaluated, producing a list l of values. Undefined values are removed. If the resulting l is composed only of numbers, the result is the average of the values, as a Real. If the list is empty, the result is 0. If the list has only Undefined values, the result is
UNDEFINED
. In other cases, the result is ERROR.Number min([ List l ])
¶The elements of l are evaluated, producing a list l of values. Undefined values are removed. If the resulting l is composed only of numbers, the result is the minimum of the values, as a Real if any value is Real, and as an Integer otherwise. If the list is empty, the result is UNDEFINED. In other cases, the result is ERROR.
Number max([ List l ])
¶The elements of l are evaluated, producing a list l of values. Undefined values are removed. If the resulting l is composed only of numbers, the result is the maximum of the values, as a Real if any value is Real, and as an Integer otherwise. If the list is empty, the result is UNDEFINED. In other cases, the result is ERROR.
String strcat(AnyType Expr1 [ , AnyType Expr2 ...])
¶Returns the string which is the concatenation of all arguments, where all arguments are converted to type
String
by functionstring(Expr)
. ReturnsERROR
if any argument evaluates toUNDEFINED
orERROR
.String join(String sep, AnyType Expr1 [ , AnyType Expr2 ...])
¶ ORString join(String sep, List list)
¶ ORString join(List list)
¶Returns the string which is the concatenation of all arguments after the first one. The first argument is the separator, and it is inserted between each of the other arguments during concatenation. All arguments which are not undefined are converted to type
String
by functionstring(Expr)
before concatenation. Undefined arguments are skipped. When there are exactly two arguments, If the second argument is a List, all members of the list are converted to strings and then joined using the separator. When there is only one argument, and the argument is a List, all members of the list are converted to strings and then concatenated.Returns
ERROR
if any argument evaluates toUNDEFINED
orERROR
.For example:
"a, b, c" = join(", ", "a", "b", "c") "abc" = join(split("a b c")) "a;b;c" = join(";", split("a b c"))
String substr(String s, Integer offset [ , Integer length ])
¶Returns the substring of
s
, from the position indicated byoffset
, with (optional)length
characters. The first character withins
is at offset 0. If the optionallength
argument is not present, the substring extends to the end of the string. Ifoffset
is negative, the value(length - offset)
is used for the offset. Iflength
is negative, an initial substring is computed, from the offset to the end of the string. Then, the absolute value oflength
characters are deleted from the right end of the initial substring. Further, where characters of this resulting substring lie outside the original string, the part that lies within the original string is returned. If the substring lies completely outside of the original string, the null string is returned.This function returns
ERROR
if greater than 3 or less than 2 arguments are given.Integer strcmp(AnyType Expr1, AnyType Expr2)
¶Both arguments are converted to type
String
by functionstring(Expr)
. The return value is an integer that will beless than 0, if
Expr1
is lexicographically less thanExpr2
equal to 0, if
Expr1
is lexicographically equal toExpr2
greater than 0, if
Expr1
is lexicographically greater thanExpr2
Case is significant in the comparison. Where either argument evaluates to
ERROR
orUNDEFINED
,ERROR
is returned.This function returns
ERROR
if other than 2 arguments are given.Integer stricmp(AnyType Expr1, AnyType Expr2)
¶This function is the same as strcmp, except that letter case is not significant.
Integer versioncmp(String left, String right)
¶This function version-compares two strings. It returns an integer
less than zero if
left
is an earlier version thanright
zero if the strings are identical
more than zero if
left
is a later version thanright
.
A version comparison is a lexicographic comparison unless the first difference between the two strings occurs in a string of digits, in which case, sort by the value of that number (assuming that more leading zeroes mean smaller numbers). Thus
7.x
is earlier than7.y
,7.9
is earlier than7.10
, and the following sequence is in order:000, 00, 01, 010, 09, 0, 1, 9, 10
.Boolean versionGT(String left, String right)
¶ ORBoolean versionGE(String left, String right)
¶As versioncmp, but for specific comparison of “Greater Than (GT)” and “Greater Than or Equal (GE)”. Returns a boolean.
Boolean versionLT(String left, String right)
¶ ORBoolean versionLE(String left, String right)
¶As versioncmp, but for specific comparison of “Less Than (LT)” and “Less Than or Equal (LE)”. Returns a boolean.
Boolean versionEQ(String left, String right)
¶As versioncmp, but for a specific comparison of equivalence. Returns a boolean.
Boolean version_in_range(String version, String min, String max)
¶Equivalent to
versionLE(min, version) && versionLE(version, max)
.String toUpper(AnyType Expr)
¶The single argument is converted to type
String
by functionstring(Expr)
. The return value is this string, with all lower case letters converted to upper case. If the argument evaluates toERROR
orUNDEFINED
,ERROR
is returned.This function returns
ERROR
if other than exactly 1 argument is given.String toLower(AnyType Expr)
¶The single argument is converted to type
String
by functionstring(Expr)
. The return value is this string, with all upper case letters converted to lower case. If the argument evaluates toERROR
orUNDEFINED
,ERROR
is returned.This function returns
ERROR
if other than exactly 1 argument is given.Integer size(AnyType Expr)
¶If Expr evaluates to a string, return the number of characters in the string. If Expr evaluate to a list, return the number of elements in the list. If Expr evaluate to a classad, return the number of entries in the ad. Otherwise,
ERROR
is returned.List split(String s [ , String tokens ] )
¶Returns a list of the substrings of
s
that have been split up by using any of the characters within stringtokens
. Iftokens
is not specified, then all white space characters are used to delimit the string.List splitUserName(String Name)
¶Returns a list of two strings. Where
Name
includes an@
character, the first string in the list will be the substring that comes before the@
character, and the second string in the list will be the substring that comes after. Thus, ifName
is"user@domain"
, then the returned list will be {“user”, “domain”}. If there is no@
character inName
, then the first string in the list will beName
, and the second string in the list will be the empty string. Thus, ifName
is"username"
, then the returned list will be {“username”, “”}.List splitSlotName(String Name)
¶Returns a list of two strings. Where
Name
includes an@
character, the first string in the list will be the substring that comes before the@
character, and the second string in the list will be the substring that comes after. Thus, ifName
is"slot1@machine"
, then the returned list will be {“slot1”, “machine”}. If there is no@
character inName
, then the first string in the list will be the empty string, and the second string in the list will beName
, Thus, ifName
is"machinename"
, then the returned list will be {“”, “machinename”}.Integer time()
¶Returns the current coordinated universal time. This is the time, in seconds, since midnight of January 1, 1970.
String formatTime([ Integer time ] [ , String format ])
¶Returns a formatted string that is a representation of
time
. The argumenttime
is interpreted as coordinated universal time in seconds, since midnight of January 1, 1970. If not specified,time
will default to the current time.The argument
format
is interpreted similarly to the format argument of the ANSI C strftime function. It consists of arbitrary text plus placeholders for elements of the time. These placeholders are percent signs (%) followed by a single letter. To have a percent sign in the output, use a double percent sign (%%). Ifformat
is not specified, it defaults to%c
.Because the implementation uses strftime() to implement this, and some versions implement extra, non-ANSI C options, the exact options available to an implementation may vary. An implementation is only required to implement the ANSI C options, which are:
%a
abbreviated weekday name
%A
full weekday name
%b
abbreviated month name
%B
full month name
%c
local date and time representation
%d
day of the month (01-31)
%H
hour in the 24-hour clock (0-23)
%I
hour in the 12-hour clock (01-12)
%j
day of the year (001-366)
%m
month (01-12)
%M
minute (00-59)
%p
local equivalent of AM or PM
%S
second (00-59)
%U
week number of the year (Sunday as first day of week) (00-53)
%w
weekday (0-6, Sunday is 0)
%W
week number of the year (Monday as first day of week) (00-53)
%x
local date representation
%X
local time representation
%y
year without century (00-99)
%Y
year with century
%Z
time zone name, if any
String interval(Integer seconds)
¶Uses
seconds
to return a string of the formdays+hh:mm:ss
. This represents an interval of time. Leading values that are zero are omitted from the string. For example,seconds
of 67 becomes “1:07”. A second example,seconds
of 1472523 = 17*24*60*60 + 1*60*60 + 2*60 + 3, results in the string “17+1:02:03”.String evalInEachContext(Expression expr, List contexts)
¶This function evaluates its first argument as an expression in the context of each Classad in the second argument and returns a list that is the result of each evaluation. The first argument should be an expression. If the second argument does not evaluate to a list of ClassAds,
ERROR
is returned.For example:
{true, false} = evalInEachContext(Prio > 2, { [Prio=3;], [Prio=1;] }) {3, 1} = evalInEachContext(Prio, { [Prio=3;], [Prio=1;] }) ERROR = evalInEachContext(Prio > 2, { [Prio=3;], UNDEFINED }) ERROR = evalInEachContext(Prio > 2, UNDEFINED)
String countMatches(Expression expr, List contexts)
¶This function evaluates its first argument as an expression in the context of each Classad in the second argument and returns a count of the results that evaluated to
True
. The first argument should be an expression. The second argument should be a list of ClassAds or a list of attribute references to classAds, or should evaluate to a list of ClassAds. This function will always return a integer value when the first argument is defined and the second argument is notERROR
.For example:
1 = countMatches(Prio > 2, { [Prio=3;], [Prio=1;] }) 1 = countMatches(Prio > 2, { [Prio=3;], UNDEFINED }) 0 = countMatches(Prio > 2, UNDEFINED)
AnyType debug(AnyType expression)
¶This function evaluates its argument, and it returns the result. Thus, it is a no-operation. However, a side-effect of the function is that information about the evaluation is logged to the evaluating program’s log file, at the
D_FULLDEBUG
debug level. This is useful for determining why a given ClassAd expression is evaluating the way it does. For example, if a condor_startd START expression is unexpectedly evaluating toUNDEFINED
, then wrapping the expression in this debug() function will log information about each component of the expression to the log file, making it easier to understand the expression.String envV1ToV2(String old_env)
¶This function converts a set of environment variables from the old HTCondor syntax to the new syntax. The single argument should evaluate to a string that represents a set of environment variables using the old HTCondor syntax (usually stored in the job ClassAd attribute Env). The result is the same set of environment variables using the new HTCondor syntax (usually stored in the job ClassAd attribute Environment). If the argument evaluates to
UNDEFINED
, then the result is alsoUNDEFINED
.String mergeEnvironment(String env1 [ , String env2, ... ])
¶This function merges multiple sets of environment variables into a single set. If multiple arguments include the same variable, the one that appears last in the argument list is used. Each argument should evaluate to a string which represents a set of environment variables using the new HTCondor syntax or
UNDEFINED
, which is treated like an empty string. The result is a string that represents the merged set of environment variables using the new HTCondor syntax (suitable for use as the value of the job ClassAd attribute Environment).
For the following functions, a delimiter is represented by a string. Each character within the delimiter string delimits individual strings within a list of strings that is given by a single string. The default delimiter contains the comma and space characters. A string within the list is ended (delimited) by one or more characters within the delimiter string.
Integer stringListSize(String list [ , String delimiter ])
¶Returns the number of elements in the string
list
, as delimited by the optionaldelimiter
string. ReturnsERROR
if either argument is not a string.This function returns
ERROR
if other than 1 or 2 arguments are given.Integer stringListSum(String list [ , String delimiter ])
¶ ORReal stringListSum(String list [ , String delimiter ])
¶Sums and returns the sum of all items in the string
list
, as delimited by the optionaldelimiter
string. If all items in the list are integers, the return value is also an integer. If any item in the list is a real value (noninteger), the return value is a real. If any item does not represent an integer or real value, the return value isERROR
.Real stringListAvg(String list [ , String delimiter ])
¶Sums and returns the real-valued average of all items in the string
list
, as delimited by the optionaldelimiter
string. If any item does not represent an integer or real value, the return value isERROR
. A list with 0 items (the empty list) returns the value 0.0.Integer stringListMin(String list [ , String delimiter ])
¶ ORReal stringListMin(String list [ , String delimiter ])
¶Finds and returns the minimum value from all items in the string
list
, as delimited by the optionaldelimiter
string. If all items in the list are integers, the return value is also an integer. If any item in the list is a real value (noninteger), the return value is a real. If any item does not represent an integer or real value, the return value isERROR
. A list with 0 items (the empty list) returns the valueUNDEFINED
.Integer stringListMax(String list [ , String delimiter ])
¶ ORReal stringListMax(String list [ , String delimiter ])
¶Finds and returns the maximum value from all items in the string
list
, as delimited by the optionaldelimiter
string. If all items in the list are integers, the return value is also an integer. If any item in the list is a real value (noninteger), the return value is a real. If any item does not represent an integer or real value, the return value isERROR
. A list with 0 items (the empty list) returns the valueUNDEFINED
.Boolean stringListMember(String x, String list [ , String delimiter ])
¶Returns
TRUE
if itemx
is in the stringlist
, as delimited by the optionaldelimiter
string. ReturnsFALSE
if itemx
is not in the stringlist
. Comparison is done withstrcmp()
. The return value isERROR
, if any of the arguments are not strings.Boolean stringListIMember(String x, String list [ , String delimiter ])
¶Same as
stringListMember()
, but comparison is done with stricmp, so letter case is not relevant.Integer stringListsIntersect(String list1, String list2 [ , String delimiter ])
¶Returns
TRUE
if the lists contain any matching elements, and returnsFALSE
if the lists do not contain any matching elements. ReturnsERROR
if either argument is not a string or if an incorrect number of arguments are given.Boolean stringListSubsetMatch(String list1, String list2 [ , String delimiter ])
¶Returns
TRUE
if all item in the stringlist1
are also in the stringlist2
, as delimited by the optionaldelimiter
string. ReturnsFALSE
iflist1
has any items that are not inlist2
. Both lists are treated as sets. Empty items and duplicate items are ignored. The return value isTRUE
iflist1
isUNDEFINED
or empty andlist2
is any string value. The return value isFALSE
iflist1
is any string value andlist2
isUNDEFINED
. The return value isUNDEFINED
if bothlist1
andlist2
areUNDEFINED
. The return value isERROR
, if any of the arguments are not either strings orUNDEFINED
Boolean stringListISubsetMatch(String list1, String list2 [ , String delimiter ])
¶Same as
stringListSubsetMatch()
, but the sets are case-insensitive.
The following six functions utilize regular expressions as defined and supported by the PCRE library. See http://www.pcre.org for complete documentation of regular expressions.
The options
argument to these functions is a string of special
characters that modify the use of the regular expressions. Inclusion of
characters other than these as options are ignored.
I
ori
Ignore letter case.
M
orm
Modifies the interpretation of the caret (^) and dollar sign ($) characters. The caret character matches the start of a string, as well as after each newline character. The dollar sign character matches before a newline character.
S
ors
The period matches any character, including the newline character.
F
orf
When doing substitution, return the full target string with substitutions applied. Normally, only the substitute text is returned.
G
org
When doing substitution, apply the substitution for every matching portion of the target string (that doesn’t overlap a previous match).
Boolean regexp(String pattern, String target [ , String options ])
¶Uses the regular expression given by string
pattern
to scan through the stringtarget
. ReturnsTRUE
whentarget
matches the regular expression given bypattern
. ReturnsFALSE
otherwise. If any argument is not a string, or ifpattern
does not describe a valid regular expression, returnsERROR
.Boolean regexpMember(String pattern, List targetStrings [ , String options ])
¶Uses the description of a regular expression given by string
pattern
to scan through a List of string ntargetStrings
. ReturnsTRUE
whentarget
matches a regular expression given bypattern
. If no strings match, and at least one item in targetString evaluated to undefined, returns undefined. If any item in targetString before a match evaluated to neither a string nor undefined, returnsERROR
.String regexps(String pattern, String target, String substitute [ , String options ])
¶Uses the regular expression given by string
pattern
to scan through the stringtarget
. Whentarget
matches the regular expression given bypattern
, the stringsubstitute
is returned, with backslash expansion performed. If any argument is not a string, returnsERROR
.String replace(String pattern, String target, String substitute [ , String options ])
¶Uses the regular expression given by string
pattern
to scan through the stringtarget
. Returns a modified version oftarget
, where the first substring that matchespattern
is replaced by the stringsubstitute
, with backslash expansion performed. Equivalent toregexps()
with thef
option. If any argument is not a string, returnsERROR
.String replaceall(String pattern, String target, String substitute [ , String options ])
¶Uses the regular expression given by string
pattern
to scan through the stringtarget
. Returns a modified version oftarget
, where every substring that matchespattern
is replaced by the stringsubstitute
, with backslash expansion performed. Equivalent toregexps()
with thefg
options. If any argument is not a string, returnsERROR
.Boolean stringList_regexpMember(String pattern, String list [ , String delimiter ] [ , String options ])
¶Uses the description of a regular expression given by string
pattern
to scan through the list of strings inlist
. ReturnsTRUE
when one of the strings inlist
is a regular expression as described bypattern
. The optionaldelimiter
describes how the list is delimited, and stringoptions
modifies how the match is performed. ReturnsFALSE
ifpattern
does not match any entries inlist
. The return value isERROR
, if any of the arguments are not strings, or ifpattern
is not a valid regular expression.String userHome(String userName [ , String default ])
¶Returns the home directory of the given user as configured on the current system (determined using the getpwdnam() call). (Returns
default
if thedefault
argument is passed and the home directory of the user is not defined.)List userMap(String mapSetName, String userName)
¶Map an input string using the given mapping set. Returns a string containing the list of groups to which the user belongs separated by commas or undefined if the user was not found in the map file.
String userMap(String mapSetName, String userName, String preferredGroup)
¶Map an input string using the given mapping set. Returns a string, which is the preferred group if the user is in that group; otherwise it is the first group to which the user belongs, or undefined if the user belongs to no groups.
String userMap(String mapSetName, String userName, String preferredGroup, String defaultGroup)
¶Map an input string using the given mapping set. Returns a string, which is the preferred group if the user is in that group; the first group to which the user belongs, if any; and the default group if the user belongs to no groups.
The maps for the
userMap()
function are defined by the following configuration macros: <SUBSYS>_CLASSAD_USER_MAP_NAMES, CLASSAD_USER_MAPFILE_<name> and CLASSAD_USER_MAPDATA_<name> (see the HTCondor-wide Configuration File Entries section).