REDUCE

21.3 Invoking Pipes

Pipes are known to almost all the operating systems where PSL is implemented for. It usually comes in two flavours, named pipes and anonymous pipes. PSL uses the anonymous pipes for unidirectional communication. One standard operation is the connection to the Gnuplot graphics system from the REDUCE computer algebra system. In the following we describe the pipes operation in PSL under Unix and Windows.

21.3.1 Pipes under Unix

The pipe interface can be made available by loading the module pipes.

(pipe-open CMD:string MODE:id):Channel expr
The Unix system tries to create the process defined by CMD using the usual Unix mechanisms like pathes etc. Depending on the MODE either the stdin or the stdout is connected to the PSL program during the evaluation. The resulting LISP I/O file is returned such that in subsequent read or write operation to this file the command input or output is used. MODE needs to be either input or output.

A pipe can be used as a normal LISP file. A close operation on the file will terminate the process. If the user wants to keep the process alive, instead of close the following function has to be used:

(abandonpipe Channel):undefined expr
This closes the pipe created by pipe-open, but the process will remain active.

Examples:

 
(load pipes)  
(setq mail (pipe-open "mail hugo@zib.de" 'output))  
(wrs mail)  
(prin2 "This is the result of (expt 10 100) ")  
(prin2t (expt 10 100))  
(wrs nil)  
(close mail)  
 
(load pipes)  
(setq unix (pipe-open "uname -s" 'input))  
(rds unix)  
(setq variant (read))  
(rds nil)  
(close unix)

21.3.2 Pipes under MS/DOS

The pipe interface can be made available by loading the module pipes.

21.3.3 Pipes under MS Windows

The pipe interface can be made available by loading the module w-pipes.