Calc utility

From Messaging Server Technical Reference Wiki
Jump to: navigation, search

The calc utility provides an interface to the MTA's internal expression parser and evaluator. Additional function "sets" can be added by specifying appropriate switches, e.g., the -mm switch provides access to the Sieve function set.


  imsimta calc [expression] 

imsimta calc Command Switches
Switch Default
-input=filename None
-output=filename None
-statement=n -statement=1
-debug[=n] -debug=4
-uav=n -uav=1
-multiple -multiple
-mm See text
-message=filename None
-symbols -nosymbols
-from -from=""
-required -required
-to None
-system -nosystem
-mtpriority=n -mtpriority=0
-source=source-channel-name -source=l







The expression to evaluate.


The calc utility is a calculator, for performing integer and string operations. See Operators in Order of Precedence for a list of basic arithmetic and symbolic operators available, and Symbol table functions for a list of functions available.

Variables can be created, and values assigned to them, using the "=" assignment operator, e.g.,

calc> a = 3 

Use Ctrl-D to exit.

In addition to its use for performing simple calculations, the imsimta calc utility may also be helpful for testing planned use of calculations in Sieve filters, or in expressions inside MTA mapping tables. Compared with the imsimta test -expression utility, the calc utility is simpler for testing the fundamentals of mathematical calculation or string manipulation, but does not test, for instance, Sieve filter-specific syntax.


-debug=n, -nodebug (default)

The -debug switch may be used to enable debug output. Specifying -debug is equivalent to specifying -debug=4.

-from=address, -to=address

(-from new in MS 6.2; -to new in MS 6.3.) The -mm and -message switches must be used in order to use -from or -to. With -from, specify the envelope From address (for instance, for purposes of Sieve filter evaluation). If not specified, the MTA's default postmaster return address is assumed. If -message is not specified, then -from has no effect. With -to, specify the envelope To address.

-input=filename, -noinput (default)

The -input switch may be used to specify a file from which to read the expressions to be evaluated.

-message=filename, -nomessage (default)

Initialize the MTA as if for message submission of the specified message. The -mm switch must be used in order to use -message. When -message is used, the -from switch and -to switch also become available.

-mm, -nomm (default)

If specified, loads the Sieve function set. This causes an MTA initialization call to be made. Use of any of the -message, -required, or -system switches requires that -mm also be specified. The -mm and -sy switches are mutually exclusive (they cannot be used with each other).

-mtpriority=n, -nomtpriority

(New in MS 8.0) -mtpriority takes a required integer argument specifying the initial MT-PRIORITY value. It may only be specified when -mm has also been specified.

-multiple (default), -nomultiple

The default, -multiple, allows evaluating multiple, comma-separated statements per physical line. Specifying -nomultiple disables this, so that only the first result (from the physical line) is returned.

-output=filename, -nooutput (default)

The -output switch may be used to specify a file to which to write the output of the calculator.

-required (default), -norequired

(New in MS 6.2.) The -mm switch must be used in order to use -required.


(New in MS 8.0) Specify the recall secret.


(New in MS 8.0) Specify the source channel; the default is l (the "L"ocal channel).


nis a bit-encoded integer. The default is -statement=1. But note that specifying -mm forces setting bit 9 (value 512), overriding whether or not -statement set that bit, to allow bracketed lists.

See the test -expression utility's description of Statement parsing flags for details on the meaning of the bits for this switch's value.

To test Sieve scripts using the "loop" construct or (new in MS 8.0) "sub" construct, note that -⁠statement=3 must be specified.

-symbols, -nosymbols (default)

The -symbols switch, if specified, enables references to environment variables. -nosymbols is the default.

-system, -nosystem (default)

(New in MS 7.0.5) The -mm switch must be used in order to use -system. If -system is specified with -mm, then the Sieve is treated as a system-level Sieve; if not, then it is treated as a user-level Sieve.


The -uav switch controls the interpretation of unassigned variables. The default is -uav=1.

calc utility's -uav switch values
Value Usage
0 Variables must be predefined; variable creation not allowed
1 Assignment defines variable; no default value
2 Define variable upon first reference; default value ""
3 Define variable upon first reference except in modify operations; default value 0
4 (New in MS 8.0/patch to MS 7.0u5) Same as value 1 (assignment defines variable; no default value), with the difference (appropriate for Sieve usage) don't create a symbol table at parse time

See also: