Operating System Utilities ************************** This package contains utilities for invoking services from the operating system. At the time of writing this documentation, these services are only available on UNIX platforms. 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. `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)' OLDNAME is the name of an existing file or directory, which will be deleted. If the operation fails, an exception is raised. `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 Bourne 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'. `std' The standard stream is shared with the calling process. `pipe(-STREAM)' A pipe is created which connects the Prolog stream STREAM to the standard stream of the new process. PID is the process identifier of the new process. `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]'. `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 `X's. The file name is that template with the six `X's replaced with a letter and the process id. `popen(+COMMAND, +MODE, ?STREAM)' Interface to the UNIX function `popen(3)'. Passes COMMAND to a new Bourne 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'. `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. `shell(+COMMAND, -STATUS)' Passes COMMAND to a new shell named by the environment variable `SHELL' for execution. The status value is returned in STATUS. `sleep(+SECONDS)' Puts the SICStus Prolog process asleep for SECOND seconds. `system' Starts a new interactive Bourne shell process. The control is returned to Prolog upon termination of the shell process. `system(+COMMAND)' Passes Command to a new Bourne shell process for execution. Succeeds if the return status value is 0. `system(+COMMAND, -STATUS)' Passes COMMAND to a new Bourne shell process for execution. The status value is returned in STATUS. `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.