------art_37562_28611333.1178981717090
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 5/12/07, Philip W. <likelink / jetsoftdev.com> wrote:
>
> Hello all,
>
>     I'm writing a Ruby shell for Ubuntu Linux 7.04. I would like my
> shell to take commands from the user, run the command, output the result
> to the command line, and log the result in a file. But I am having
> trouble getting the Ruby shell to output the result to the command line,
> and log the command. I've tried everything I can think of - using the
> backticks method (``), exec(), system(), and IO.popen, strange
> combinations of the mentioned and eval(), but nothing satisfies both of
> my requirements. Sometimes the shell will output the command result to
> the shell, but it won't log it. Sometimes it will log the command
> result, but it won't output it to the shell. Sometimes it does one or
> both things, but it only outputs or logs some of the command result. I
> would appreciate any help that I could get on ways to make this work.


Perhaps I'm missing your ultimate point here, but one major problem I see is
that you can't really just slurp out the "results" for, say, a text editor
(such as vi or pico) or any sort of interactive script. If your shell
doesn't allow access to those sort of programs, it wouldn't be particularly
useful (unless you envision a use for a shell that only allows you to
perform the most basic of commands).

Is it necessary to log all output? Generally "system" will give you the
closest (but not exact) match to what happens when you normally run a
program under a shell, but of course that doesn't return the output of the
command you run.. although it does let you get into interactive apps, etc.

From what I can tell, the main problem you appear to be running into is that
some programs are not just sending output to stdout, or are redefining what
stdout is. This is why shells often do lots of freaky things to make sure
output ends up where it should.

Cheers,
Peter Cooper
http://www.rubyinside.com/

------art_37562_28611333.1178981717090--