Wolfram System Sessions

Command-Line Options and Environment Variables

Typical command-line options for Wolfram System executables.

If the Wolfram System front end is called with a notebook file as a command-line argument, then this notebook will be made the initial selected notebook. Otherwise, a new notebook will be created for this purpose.

Wolfram Language kernels and front ends can also take additional command-line options specific to particular window environments.

Environment variables.

The Wolfram System will read the values of operating system environment variables, and will use these values in addition to any command-line options explicitly given.

Initialization

On startup, the Wolfram Language kernel does the following:

Performs license management operations.

Runs Wolfram Language commands specified in any -run options passed to the kernel executable.

Runs the Wolfram Language commands in the systemwide initialization file $BaseDirectory/Kernel/init.m.

Runs the Wolfram Language commands in the user-specific initialization file $UserBaseDirectory/Kernel/init.m.

Loads init.m and Kernel/init.m files in Autoload directories.

Begins running the main loop.

The Main Loop

All Wolfram System sessions repeatedly execute the following main loop:

Read in input.

Apply (RefLink[$PreRead, paclet:ref/$PreRead]) function, if defined, to the input string.

Print syntax warnings if necessary.

Apply (RefLink[$SyntaxHandler, paclet:ref/$SyntaxHandler]) function if there is a syntax error.

Assign (RefLink[InString, paclet:ref/InString])[n].

Apply (RefLink[$Pre, paclet:ref/$Pre]) function, if defined, to the input expression.

Assign (RefLink[In, paclet:ref/In])[n].

Evaluate expression.

Apply (RefLink[$Post, paclet:ref/$Post]) function, if defined.

Assign (RefLink[Out, paclet:ref/Out])[n], stripping off any formatting wrappers.

Apply (RefLink[$PrePrint, paclet:ref/$PrePrint]) function, if defined.

Assign (RefLink[MessageList, paclet:ref/MessageList])[n] and clear (RefLink[$MessageList, paclet:ref/$MessageList]).

Print expression, if it is not (RefLink[Null, paclet:ref/Null]).

Increment (RefLink[$Line, paclet:ref/$Line]).

Clear any pending aborts.

Note that if you call the Wolfram Language via the Wolfram Symbolic Transfer Protocol (WSTP) from within an external program, then you must effectively create your own main loop, which will usually differ from the one described above.

Messages

During a Wolfram System session messages can be generated either by explicit calls to (RefLink[Message, paclet:ref/Message]), or in the course of executing other built-in functions.

Message names.

If no language is specified for a particular message, text for the message is sought in each of the languages specified by (RefLink[$Language, paclet:ref/$Language]). If f::name is not defined, a definition for (RefLink[General, paclet:ref/General])::name is sought. If still no message is found, any value defined for (RefLink[$NewMessage, paclet:ref/$NewMessage]) is applied to f and "name".

(RefLink[Quiet, paclet:ref/Quiet])[expr] evaluates expr while preventing messages from being printed during the evaluation. (RefLink[Off, paclet:ref/Off])[message] prevents a specified message from ever being printed. (RefLink[Check, paclet:ref/Check]) allows you to determine whether particular messages were generated during the evaluation of an expression. (RefLink[$MessageList, paclet:ref/$MessageList]) and (RefLink[MessageList, paclet:ref/MessageList])[n] record all the messages that were generated during the evaluation of a particular line in a Wolfram System session.

Messages are specified as strings to be used as the first argument of (RefLink[StringForm, paclet:ref/StringForm]). (RefLink[$MessagePrePrint, paclet:ref/$MessagePrePrint]) is applied to each expression to be spliced into the string.

Termination

Wolfram System termination.

There are several ways to end a Wolfram System session. If you are using the Wolfram System interactively, typing (RefLink[Exit, paclet:ref/Exit])[] or (RefLink[Quit, paclet:ref/Quit])[] on an input line will always terminate the Wolfram System.

If you are taking input for the Wolfram Language from a file, the Wolfram System will exit when it reaches the end of the file. If you are using the Wolfram System interactively, it will still exit if it receives an end-of-file character (typically Ctrl+d). You can stop the Wolfram System from doing this by setting (RefLink[$IgnoreEOF, paclet:ref/$IgnoreEOF])=(RefLink[True, paclet:ref/True]).

Network License Management

Single-machine and network licenses.

Copies of the Wolfram System can be set up with either single-machine or network licenses. A network license is indicated by a line in the mathpass file starting with !name, where name is the name of the server machine for the network license.

Network licenses are controlled by the Wolfram System license management program mathlm, which is run on the server machine. This program must be running whenever a Wolfram System with a network license is being used. Typically you will want to set up your system so that mathlm is started whenever the system boots.

Ways to start the network license manager under Microsoft Windows.

Ways to start the network license manager on Macintosh and Linux systems.

When mathlm is not started directly from a command line, it normally sets itself up as a background process, and continues running until it is explicitly terminated. Note that if one mathlm process is running, any other mathlm processes you try to start will automatically exit immediately.

Some command-line options for mathlm.

For more detailed information on mathlm, see "Mathematica System Administration".

Monitoring network license activity.

If monitorlm is run in an environment where a web browser can be started, it will automatically generate HTML output in the browser. Otherwise it will generate plain text.

Some command-line options for monitorlm.