Home Contents Index Summary Previous Next

2.1 Starting SWI-Prolog from the Unix Shell

It is advised to install SWI-Prolog as `pl' in the local binary directory. SWI-Prolog can then be started from the Unix shell by typing `pl'. The system will boot from the system's default boot file, perform the necessary initialisations and then enter the interactive top level.

After the necessary system initialisation the system consults (see consult/1) the user's initialisation file. This initialisation file should be named `.plrc' and reside either in the current directory or in the user's home directory. If both exist the initialisation file from the current directory is loaded. The name of the initialisation file can be changed with the `-f file' option. After loading the initialisation file SWI-Prolog executes a user initialisation goal. The default goal is a system predicate that prints the banner message. The default can be modified with the `-g goal' option. Next the toplevel goal is started. Default is the interactive Prolog loop (see prolog/0). The user can overwrite this default with the `-t toplevel' option.

2.1.1 Command Line Options

The full set of command line options is given below:

-help
When given as the only option, it summarises the most important options.

-v
When given as the only option, it summarises the version and the architecture identifier.

-arch
When given as the only option, it prints the architecture identifier (see feature(arch, Arch)) and exits.

-Lsize[km]
Give local stack limit (2 Mbytes default). Note that there is no space between the size option and its argument. By default, the argument is interpreted in Kbytes. Postfixing the argument with m causes the argument to be interpreted in Mbytes. The following example specifies 32 Mbytes local stack. % pl -L32m

A maximum is useful to stop buggy programs from claiming all memory resources. -L0 sets the limit to the highest possible value.

-Gsize[km]
Give global stack limit (4 Mbytes default). See -L for more details.

-Tsize[km]
Give trail stack limit (4 Mbytes default). This limit is relatively high because trail-stack overflows are not often caused program bugs. See -L for more details.

-Asize[km]
Give argument stack limit (1 Mbytes default). The argument stack limits the maximum nesting of terms that can be compiled and executed. The SWI-Prolog does `last-argument optimisation' to avoid many deeply nested structure using this stack. Enlarging this limit is only necessary in extreme cases. See -L for more details.

-Hsize[km]
Give malloc() heap limit. The default is to raise the limit as high as possible. This option only applies to machines using the mmap() function for allocating the Prolog stacks. See -L for more details.

-c file ...
Compile files into an `intermediate code file'. See section 2.7.

-o output
Used in combination with -c or -b to determine output file for compilation.

-O
Optimised compilation. See please/3.

-f file
Use file as initialisation file instead of `.plrc'. `-f none' stops SWI-Prolog from searching for an initialisation file.

-F script
Selects a startup-script from the SWI-Prolog home directory. The script-file is named <script>.rc. The default script name is deduced from the executable, taking the leading alphanumerical characters (letters, digits and underscore) from the program-name. -F none stops looking for a script. Intended for simple management of slightly different versions. One could for example write a script iso.rc and then select ISO compatibility mode using pl -F iso or make a link from iso-pl to pl.

-g goal
Goal is executed just before entering the top level. Default is a predicate which prints the welcome message. The welcome message can thus be suppressed by giving -g true. goal can be a complex term. In this case quotes are normally needed to protect it from being expanded by the Unix shell.

-t goal
Use goal as interactive toplevel instead of the default goal prolog/0. goal can be a complex term. If the toplevel goal succeeds SWI-Prolog exits with status 0. If it fails the exit status is 1. This flag also determines the goal started by break/0 and abort/0. If you want to stop the user from entering interactive mode start the application with `-g goal' and give `halt' as toplevel.

-tty
Switches tty control (using ioctl(2)) on (+tty) or off (-tty). Normally tty control is switched on. This default depends on the installation. You may wish to switch tty control off if Prolog is used from an editor such as Emacs. If switched off get_single_char/1 and the tracer will wait for a return.

-x bootfile
Boot from bootfile instead of the system's default boot file. A bootfile is a file resulting from a Prolog compilation using the -b or -c option or a program saved using qsave_program/[1,2].

-r restorefile
Restore a state created by save_program/[1,2] or save/[1,2] using the new-style saved-states. Equivalent to restore(restorefile) from Prolog.

-p alias=path1[:path2 ... ]
Define a path alias for file_search_path. alias is the name of the alias, path1 ... is a : separated list of values for the alias. A value is either a term of the form alias(value) or pathname. The computed aliases are added to file_search_path/2 using asserta/1, so they precede predefined values for the alias. See file_search_path/2 for details on using this file-location mechanism.

--
Stops scanning for more arguments, so you can pass arguments for your application after this one.

The following options are for system maintenance. They are given for reference only.

-b initfile ...-c file ...
Boot compilation. initfile ... are compiled by the C-written bootstrap compiler, file ... by the normal Prolog compiler. System maintenance only.

-d level
Set debug level to level. Only has effect if the system is compiled with the -DO_DEBUG flag. System maintenance only.