Go to the first, previous, next, last section, table of contents.


Operating System Utilities

This package contains utilities for invoking services from the operating system. To load the package, enter the query

| ?- use_module(library(system)).

Certain predicates described below take names of files or directories as arguments. These must be given as atoms, and the predicates below will not call absolute_file_name/2 on them.

Some predicates are described as invoking the default shell. Specifically this means invoking `/bin/sh' on UNIX platforms. On MSDOS, Windows and OS/2, the command interpreter given by the environment variable COMSPEC is invoked.

datime(-Datime)
Datime is a timestamp of the form datime(Year,Month,Day,Hour,Min,Sec) containing the current date and time. All fields are integers.
delete_file(+FileName,+Options)
FileName is the name of an existing file or directory. Options is a list of options. Possible options are directory, recursive or ignore. If FileName is not a directory it is deleted, otherwise if the option directory is specified but not recursive, the directory will be deleted if it is empty. If recursive is specified and FileName is a directory, the directory and all its subdirectories and files will be deleted. If the operation fails, an exception is raised unless the ignore option is specified.
delete_file(+FileName)
Equivalent to delete_file(FileName,[recursive]).
directory_files(+Directory,-FileList)
FileList is the list of entries (files, directories, etc.) in Directory.
make_directory(+DirectoryName)
Makes a new directory.
environ(?Var, ?Value)
Var is the name of an environment variable, and Value is its value. Both are atoms. Can be used to enumerate all current environment variables.
exec(+Command, [+Stdin,+Stdout,+Stderr], -Pid)
Passes Command to a new default shell process for execution. The standard I/O streams of the new process are connected according to what is specified by the terms +Stdin, +Stdout, and +Stderr respectively. Possible values are:
null
Connected to `/dev/null' or equivalent.
std
The standard stream is shared with the calling process. Note that the standard stream may not be referring to a console if the calling process is "windowed". To portably print the output from the subprocess on the Prolog console, pipe/1 must be used and the program must explicitly read the pipe and write to the console. Similarly for the input to the subprocess.
pipe(-Stream)
A pipe is created which connects the Prolog stream Stream to the standard stream of the new process. It must be closed using close/1; it is not closed automatically when the process dies.
Pid is the process identifier of the new process. On UNIX, the subprocess will be detached provided none of its standard streams is specified as std. This means it will not receive an interruption signal as a result of ^C being typed.
file_exists(+FileName)
FileName is the name of an existing file or directory.
file_exists(+FileName, +Permissions)
FileName is the name of an existing file or directory which can be accessed according to Permissions. Permissions is an atom, an integer (see access(2)), or a list of atoms and/or integers. The atoms must be drawn from the list [read,write,search,exists].
file_property(+FileName, ?Property)
FileName has the property Property. The possible properties are:
type(Type)
Type is one of regular, directory, fifo, symlink, socket or unknown.
size(Size)
Size is the size of FileName.
mod_time(ModTime)
ModTime is the time of the last modification of FileName.
If Property is uninstantiated, the predicate will enumerate the properties on backtracking.
host_id(-HID)
HID is the unique identifier, represented by an atom, of the host executing the current SICStus Prolog process.
host_name(-HostName)
HostName is the standard host name of the host executing the current SICStus Prolog process.
pid(-PID)
PID is the identifier of the current SICStus Prolog process.
kill(+Pid, +Signal)
Sends the signal Signal to process Pid.
mktemp(+Template, -FileName)
Interface to the UNIX function mktemp(3). A unique file name is created and unified with FileName. Template should contain a file name with six trailing Xs. The unique file name is that template with the six Xs replaced by a character string.
popen(+Command, +Mode, ?Stream)
Interface to the UNIX function popen(3). Passes Command to a new default shell process for execution. Mode may be either read or write. In the former case the output from the process is piped to Stream. In the latter case the input to the process is piped from Stream. Stream may be read/written using the ordinary StreamIO predicates. It must be closed using close/1; it is not closed automatically when the process dies.
rename_file(+OldName, +NewName)
OldName is the name of an existing file or directory, which will be renamed to NewName. If the operation fails, an exception is raised.
shell
Starts a new interactive shell named by the environment variable SHELL. The control is returned to Prolog upon termination of the shell process.
shell(+Command)
Passes Command to a new shell named by the environment variable SHELL for execution. Succeeds if the return status value is 0. On MSDOS, Windows or OS/2, if SHELL is defined it is expected to name a UNIX like shell which will be invoked with the argument -c Command. If SHELL is undefined, the shell named by COMSPEC will be invoked with the argument /C Command.
shell(+Command, -Status)
Passes Command to a new shell named by the environment variable SHELL for execution. The status value is returned in Status. See also shell/1 above.
sleep(+Seconds)
Puts the SICStus Prolog process asleep for Second seconds.
system
Starts a new interactive default shell process. The control is returned to Prolog upon termination of the shell process.
system(+Command)
Passes Command to a new default shell process for execution. Succeeds if the return status value is 0.
system(+Command, -Status)
Passes Command to a new default shell process for execution. The status value is returned in Status.
tmpnam(-FileName)
Interface to the ANSI C function tmpnam(3). A unique file name is created and unified with FileName.
wait(+Pid, -Status)
Waits for the child process Pid to terminate. The exit status is returned in Status. The function is similar to that of the UNIX function waitpid(3).
working_directory(?OldDirectory, ?NewDirectory)
OldDirectory is the current working directory, and the working directory is set to NewDirectory. In particular, the goal working_directory(Dir,Dir) unifies Dir with the current working directory without changing anything.


Go to the first, previous, next, last section, table of contents.