Dear all,
I experience a problem with Open.pipe, which I do not understand. For
most applications, I am able to read their stdout/stderr into Oz. For
some applications, however, this output does not show up in Oz. There
output works perfectly fine on the terminal though, including
redirection of their output into files or pipes. What can be the
reasons that some program outputting to stdout/stderr works perfectly
fine on the commandline, but is quasi silent for Oz?
The programs I am actually interested in (sendOSC/dumpOSC, see http://
www.cnmat.berkeley.edu/OpenSoundControl/) are probably not installed
on your machine ;-) I found another application, though, which shows
the same problem: the interactive python interpreter. Below please
find some code which demonstrates the problem. Moreover, I played
around with some Perl scripts and realised that certain lines in a
Perl script stop Oz getting any input (they still work perfectly at
the terminal). I don't include the said Perlscript here, as it is
rather messy...
Any idea? Thank you very much!
Best
Torsten
--
Torsten Anders
Interdisciplinary Centre for Computer Music Research
University of Plymouth
http://strasheela.sourceforge.net
http://www.torsten-anders.de
---------------------------------------------------------------------
declare
/** %% Provides an interface to interactive commandline programs like
a shell or an interpreter.
%% */
%% Transformation of def by Christian Schulte in "Open Programming in
Mozart"
class Shell from Open.pipe Open.text
/** %% Start interactive program Cmd (VS) with Args (list of VSs).
%% */
meth init(cmd:Cmd<="sh" args:Args<=["-s"])
Open.pipe,init(cmd:Cmd args:Args)
end
/** %% Feed Cmd (a VS) to the interactive program. Use one of the
output/show methods to retrieve results.
%% */
meth cmd(Cmd)
Open.text,putS(Cmd)
end
/** %% Show any results and output of each command fed to the
shell at stdout.
%% */
meth showAll
Line = Open.text,getS($)
in
{Wait Line}
case Line of false then
{System.showInfo "Process has died."} {self close}
else {System.showInfo Line}
{self showAll}
end
end
/** %% Return the next line (a string) of any result. In case the
shell has died, nil is returned.
%% */
meth outputLine($)
case Open.text,getS($) of false then
{self close}
nil
elseof S then S
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ls in plain sh works fine (watch output in emulator)
declare
MyShell = {New Shell init}
{MyShell showAll}
{MyShell cmd("ls -l ~")}
{MyShell close}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% The the Interactive Ruby Shell works nicely too
declare
MyShell = {New Shell init(cmd:irb args:nil)}
{MyShell showAll}
{MyShell cmd("1 + 2")}
{MyShell cmd("def fact(n)
if n <= 1
1
else
n * fact(n - 1)
end
end")}
{MyShell cmd("n=5")}
{MyShell cmd("fact(n)")}
{MyShell close}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% !! However, python does not output anything
declare
MyShell = {New Out.shell init(cmd:python args:nil)}
{MyShell showAll}
%% !! no greeting is shown, no input is echoed, no results are printed
%% on the commandline, however, this works fine
{MyShell cmd("1 + 2")}
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users