The functor connect.ozf provides a simple way 
    to connect external processes to an Oz process. The user
    can freely chose between socket or pipe connections.
    The implementation of both kinds of connections 
    is hidden from the user so that the connection can
    be switched easily. This abstraction is typically useful 
    for Oz written systems that run on various platforms or 
    with various configurations.
 
   Connect: ShellCmd x unit(args:Args ...)  ->  unit(stream:String
                                                     kill:->
                                                     send:String->)
            ShellCmd = VirtualString
            Args     = list(VirtualString)
The external process receives its input on the stream 
Connect.stream and sends its output via 
Connect.send. 
connect.ozfconnect.ozf exports a record 
Connect containing two implementations of 
the function Connect: 
 
    Connect.pipe 
    Connect.socket
 
 Both functions can connect external processes but of 
 different kind:
 Connect.pipe connects external processes that
 send input and output to the standard input/output files
 (StdIn and StdOut).
 Connect.socket connects Oz to external processes.
 Such external processes are connected via a socket with port
 PortNumber over which they send their input/output. 
 To access the socket with PortNumber the external 
 process requires an extra option when called from a shell:
 The external process behaves as a 
     --port=PortNumber
PortNumber (and not 
as a server). The external process is started, connects to the 
socket with this port, and sends its input and output
to there.
     ShellCmd Arg1 ... Argn [--port=PortNumber]
 
 then you can also invoke it from Oz by executing the
 following statement (which does not require the port
 number):
     Kind = socket % pipe
     Process = {Connect.Kind ShellCmd unit(args:[Arg1 ... Argn])}
 
Note that both kinds of connections are established in
analogy. The choice depends only on the value of the
variable Kind. This makes it very simple 
for the user of this package to select and change the 
kind of connection required (either socket or pipe).
Process.stream. You can also send 
input to the process by calling Process.send.
declare [Connect] = {Module.link ['x-ozlib://niehren/external-process/connect.ozf']}
declare Connection = {Connect.pipe cat unit(args:nil)}
{Browse Connection.stream}
{Connection.send hiho}
{Connection.send holladihi}
{Connection.kill}
 
input-output.oz provides a generic 
  way to define input-output interfaces for Oz processes (which
  can then be used as external processes). 
If you want to write external processes with Oz, then you might want to do it such way that you create both kinds of input-output interfaces for your process. In this case you can frist define an abstract process and then apply it to wrap a concrete interface around.
 An abstract procedure is a process that is abstracted 
 over its input-output interface, i.e. over an input
 stream and a procedure to send output:
 
   AbstractProcess: ( string x (string -> ) ) ->
 
input-output.ozfinput-output.ozf exports a 
 record InputOutput which contains two 
 procedures InputOutput.standard and 
 InputOutput.toSocket of the following type:
  
    InputOutput.standard: AbstractProcess ->
    InputOutput.socket: AbstractProcess ->
 
 The procedure InputOutput.standard turns an
 abstract process into a running process which uses standard
 input and output. The procedure InputOutput.socket  
 turns an abstracted process into a process which 
 accesses a port number when called from the shell
 via the following option:
  
  
    --port=PortNumber
  
   
 It then sends input and output to the socket with
 that port number. 
cat process is turned into an external
process written in Oz that is equipped with a socket 
interface for input output.
functor
import   
   InputOutput at 'x-ozlib://niehren/external-process/input-output.ozf'
   Connect     at 'x-ozlib://niehren/external-process/connect.ozf'
export
   Cat
define
proc{AbstractCat InputStream SendOutput}
   Process = {Connect.pipe cat unit(args:nil)}
in
   SendOutput = Process.send
   InputStream = Process.stream
end
Cat = {InputOutput.socket AbstractCat}
end
 
niehren-external-process-1.1.pkg to
a file and execute the following command 
in a shell (in the same directory where the file resides):
ozmake --install --package=niehren-external-process-x.x.x.pkg
If you want to extract the source in the actual directory 
then call ozmake as follows:
ozmake --extract --package=niehren-external-process-x.x.x.pkg