Spawns a command interpreter and executes Command.
Note that, despite the name,
unix/1 works on both UNIX and Windows.
Spawns a shell process and executes Command.
Spawns a shell process and executes Command. The exit status
of the executed command is returned in Status.
Changes working directory to Path.
Returns in ArgList the list of commandline arguments as Prolog objects.
Returns in ArgList the list of commandline arguments as a list
unix(cd) changes the working directory of Prolog (and of Emacs if
running under the editor interface) to your home directory. Note that
the <ESC> x cd command under Emacs has the same effect as this,
except that Emacs also provides filename completion.
If the return status of Command is 0,
)) succeeds, otherwise it fails.
)) returns the status of the executed
command, similar to the function
system(3). The low-order 8 bits
of the Status is the value returned by the system call
wait(2V) and the
next 8-bits higher up in the Status has the shell exit status if the
shell was not interrupted by a signal. An exit status of 127 indicates
that the shell could not be executed.
To start up an interactive shell, type
If ArgList is instantiated to a term that does not unify with
the result returned,
)) will simply fail.
unix/1is not sufficiently instantiated.
To list the QOF files in the current working directory:
| ?- unix(shell('ls -l *.qof')). -rw-rw-r-- 1 joe 9152 Oct 20 1990 table.qof -rw-rw-r-- 1 joe 576 Oct 25 1990 test.qof yes
Alternatively, enter a command interpreter, execute commands, and type exit to return to prolog:
| ?- unix(shell). % ls -l *.qof -rw-rw-r-- 1 joe 9152 Oct 20 1990 table.qof -rw-rw-r-- 1 joe 576 Oct 25 1990 test.qof % exit yes | ?-
If Prolog was invoked using the command (A), the command line arguments can be retrieved as in (B):
% prolog screaming yellow + yellow.pl (A) . . . | ?- unix(argv(ArgList)). (B) ArgList = [screaming, yellow]