/usr/share/mozart/doc/op/node17.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>6.1 Example: A Shell in Oz</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node16.html">- Up -</A></TD></TR></TABLE><DIV id="section.pipe.shell"><H2><A name="section.pipe.shell">6.1 Example: A Shell in Oz</A></H2><P>Suppose, we want to start and control a Unix Bourne shell <CODE>sh</CODE> (see <CODE>sh(n)</CODE>) by an Oz program. We first have to start a Unix process running the shell and then we need a connection to this shell to send commands to it and receive its output.</P><P>This can be done with class <CODE>Open<SPAN class="keyword">.</SPAN>pipe</CODE><A name="label152"></A>. Program <A href="node17.html#prog.shell">Program 6.1</A> shows the definition of a shell class. <A name="label153"></A> </P><DIV class="program" id="prog.shell"><HR><P><A name="prog.shell"></A></P></DIV><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">class</SPAN> <SPAN class="type">Shell</SPAN> <SPAN class="keyword">from</SPAN><SPAN class="type"> Open.pipe Open.text</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN> <BR> Open<SPAN class="keyword">.</SPAN>pipe<SPAN class="keyword">,</SPAN>init(cmd:<SPAN class="string">"sh"</SPAN> args:[<SPAN class="string">"-s"</SPAN>]) <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">cmd</SPAN>(Cmd) <BR> Open<SPAN class="keyword">.</SPAN>text<SPAN class="keyword">,</SPAN>putS(Cmd) <BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">show</SPAN> <BR> <SPAN class="keyword">case</SPAN> Open<SPAN class="keyword">.</SPAN>text<SPAN class="keyword">,</SPAN>getS($) <SPAN class="keyword">of</SPAN> <SPAN class="keyword">false</SPAN> <SPAN class="keyword">then</SPAN> <BR> {Browse <SPAN class="string">'Shell has died.'</SPAN>} {<SPAN class="keyword">self</SPAN> close}<BR> <SPAN class="keyword">elseof</SPAN> S <SPAN class="keyword">then</SPAN> {Browse S}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><DIV class="program"><P class="caption"><STRONG>Program 6.1:</STRONG> A shell class.</P><HR></DIV><P> Creating a shell object by </P><DL class="anonymous"><DD class="code"><CODE>S={New Shell init}</CODE></DD></DL><P> the command <CODE>sh</CODE> is executed in a newly created process. The command <CODE>sh</CODE> gets the argument <CODE>-s</CODE> to signal that the shell should read from standard input. The forked process is connected by its standard input and standard output to the created <CODE>Shell</CODE> object. </P><P>By inheriting from the class <CODE>Open<SPAN class="keyword">.</SPAN>text</CODE><A name="label155"></A> we can simply send text to the running <CODE>sh</CODE> process by using the <CODE>putS</CODE> method, and receive lines of text by using the <CODE>getS</CODE> method. </P><P>If we want to see the files in our home directory, we will first navigate to it by <CODE>cd(1)</CODE>, and then issue the <CODE>ls(1)</CODE> command: </P><DL class="anonymous"><DD class="code"><CODE>{S cmd(cd)}<BR>{S cmd(ls)}</CODE></DD></DL><P> Now we can incrementally request the names of the files by </P><DL class="anonymous"><DD class="code"><CODE>{S show}</CODE></DD></DL><P> and they will appear in the Browser window. </P><P>Closing the object and the shell is done simply by </P><DL class="anonymous"><DD class="code"><CODE>{S close}</CODE></DD></DL><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node16.html">- Up -</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|