CallSystem(cmd : string)
Darwin allows users to execute operating system commands. The CallSystem command accepts a single parameter cmd of type string.
The contents of cmd will be executed by the underlying operating
system and the value it returns is subsequently returned by the CallSystem command.
This ability is especially useful for examining files before
reading/writing to/from them. For example, by using the UNIX [26]
command ls, we can check if a specific file exists in the
current directory.
> CallSystem('ls Sample/arrays'); # if it exists, 0 is returned. > CallSystem('ls Sample/nofile'); # Unix returns value 512.Chapter
TimedCallSystem(cmd : string, timeout : posint)
The TimedCallSystem command operates in the same manner as the CallSystem command except it takes an optional second parameter timeout of
type posint. When a second argument is supplied, Darwin
passes the contents of cmd to the operating system for execution.
If the operating system does not complete
execution of the command within this bound, the result [-1,
(Timeout)] is returned. If the operating system does respond within
this time bound, a list with two items is returned. The first element of
this list is the value returned by the system command and the second
element is a string containing the output generated by the system
command.
Chapter - Calling External Functions gives an example
application of using these and related commands.