Overview

The predicate described here, unix/1, provides the most commonly needed access to the operating system. This minor extension to the Prolog system should be sufficient for most of your needs. However, you can also extend the Prolog system with additional C code, including system calls, using the foreign function interface (see fli-p2f).

The reason for channeling all the interaction with the operating system through a single built-in predicate, rather than having separate predicates for each function, is simply to localize the system dependencies. Admittedly, this makes for more cumbersome commands, so you may wish to put some clauses such as these in your prolog.ini file:

     
     cd :- unix(cd).
     cd(X) :- unix(cd(X)).
     

Initialization files are discussed in ref-pro.