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(Year,Month,Day,Hour,Min,Sec)
containing the current date and time. All fields are integers.
delete_file(+FileName,+Options)
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)
delete_file(FileName,[recursive])
.
directory_files(+Directory,-FileList)
make_directory(+DirectoryName)
environ(?Var, ?Value)
exec(+Command, [+Stdin,+Stdout,+Stderr], -Pid)
null
std
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)
close/1
; it is not closed automatically when the process dies.
std
. This means it will not receive an
interruption signal as a result of ^C being typed.
file_exists(+FileName)
file_exists(+FileName, +Permissions)
[read,write,search,exists]
.
file_property(+FileName, ?Property)
type(Type)
regular
, directory
, fifo
,
symlink
, socket
or unknown
.
size(Size)
mod_time(ModTime)
host_id(-HID)
host_name(-HostName)
pid(-PID)
kill(+Pid, +Signal)
mktemp(+Template, -FileName)
popen(+Command, +Mode, ?Stream)
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)
shell
SHELL
. The control is returned to Prolog upon termination of the
shell process.
shell(+Command)
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)
SHELL
for execution. The status value is returned in
Status. See also shell/1
above.
sleep(+Seconds)
system
system(+Command)
system(+Command, -Status)
tmpnam(-FileName)
wait(+Pid, -Status)
waitpid(3)
.
working_directory(?OldDirectory, ?NewDirectory)
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.