The Zeek scripting language supports a number of directives that can affect which scripts will be loaded or which lines in a script will be executed. Directives are evaluated before script execution begins.
Expands to the directory pathname where the current script is located.
print "Directory:", @DIR;
Expands to the filename of the current script.
print "File:", @FILENAME;
Marks the current script as deprecated. This can be placed anywhere in the script, but a good convention is to put it as the first line. You can also supply additional comments.
@deprecated "Use '@load foo' instead"
Loads the specified Zeek script, specified as the relative pathname
of the file (relative to one of the directories in Zeek’s file search path).
If the Zeek script filename ends with
.zeek, then you don’t need to
specify the file extension. The filename cannot contain any whitespace.
In this example, Zeek will try to load a script
policy/misc/capture-loss.zeek by looking in each directory in the file
search path (the file search path can be changed by setting the
If you specify the name of a directory instead of a filename, then
Zeek will try to load a file in that directory called
(presumably that file will contain additional
In this example, Zeek will try to load a file
by looking in each directory in the file search path:
The purpose of this directive is to ensure that all script dependencies
are satisfied, and to avoid having to list every needed Zeek script
on the command-line. Zeek keeps track of which scripts have been
loaded, so it is not an error to load a script more than once (once
a script has been loaded, any subsequent
for that script are ignored).
Activate a dynamic plugin with the specified plugin name. The specified plugin must be located in Zeek’s plugin search path. Example:
By default, Zeek will automatically activate all dynamic plugins found
in the plugin search path (the search path can be changed by setting
the environment variable
ZEEK_PLUGIN_PATH to a colon-separated list of
directories). However, in bare mode (
zeek -b dynamic plugins can be
activated only by using
load-plugin or by specifying the full
plugin name on the Zeek command-line (e.g.,
zeek Demo::Rot13 or by
setting the environment variable
ZEEK_PLUGIN_ACTIVATE to a
comma-separated list of plugin names.
This works similarly to
load except that in this case the filename
represents a signature file (not a Zeek script). If the signature filename
sig then you don’t need to specify the file extension
load-sigs directive. The filename cannot contain any
In this example, Zeek will try to load a signature file
The format for a signature file is explained in the documentation for the Signature Framework.
This specifies a Zeek script that we don’t want to load (so a subsequent attempt to load the specified script will be skipped). However, if the specified script has already been loaded, then this directive has no affect.
In the following example, if the
has not been loaded yet, then Zeek will not load it:
Specifies a filename prefix to use when looking for script files to load automatically. The prefix cannot contain any whitespace.
In the following example, the prefix
cluster is used and all prefixes
that were previously specified are not used:
@prefixes = cluster
In the following example, the prefix
cluster-manager is used in
addition to any previously-specified prefixes:
@prefixes += cluster-manager
The way this works is that after Zeek parses all script files, then for each
loaded script Zeek will take the absolute path of the script and then
it removes the portion of the directory path that is in Zeek’s file
search path. Then it replaces each
/ character with a period
and then prepends the prefix (specified in the
followed by a period. The resulting filename is searched for in each
directory in Zeek’s file search path. If a matching file is found, then
the file is automatically loaded.
For example, if a script called
local.zeek has been loaded, and a prefix
test was specified, then Zeek will look for a file named
test.local.zeek in each directory of Zeek’s file search path.
An alternative way to specify prefixes is to use the
The specified expression must evaluate to type
bool. If the
value is true, then the following script lines (up to the next
@endif) are available to be executed.
@if ( ver == 2 ) print "version 2 detected"; @endif
This works like
@if, except that the result is true if the specified
identifier is defined.
@ifdef ( pi ) print "pi is defined"; @endif
This works exactly like
@ifdef, except that the result is true if the
specified identifier is not defined.
@ifndef ( pi ) print "pi is not defined"; @endif
This directive is optional after an
@ifndef. If present, it provides an else clause.
@ifdef ( pi ) print "pi is defined"; @else print "pi is not defined"; @endif
This directive is required to terminate each
This directive is not meant to be used directly from user scripts. Internally,
it’s used by interactive-debugger features (
zeek -d) that allow arbitrary
expressions to be parsed and evaluated on their own rather than incorporated
into the usual Zeek syntax-tree formed from parsing script files.