ruby/GTK : Embedded terminal or redirecting process output

Hi,

Using ruby-gnome2 (gtk) I'd like to embed a terminal in a window, or
redirect the output of a child process into a text editor.

Something like
      sbtn.signal_connect("pressed") {
         system('ls')
         }

... launch the command 'ls' but is not portable and I don't know how to
redirect the output into a gtk text editor, not in the original
terminal window.

Something like
      sbtn.signal_connect("pressed") {
         lsproc = IO.popen('ls')
         p Process.waitpid(lsproc.pid)
         p $?
         }
... is portable, but still does not redirect the output.

Could someone give me a pointer to begin with ?

Thanks,
Mickael.

Mickael Faivre-Macon wrote:

Using ruby-gnome2 (gtk) I'd like to embed a terminal in a window, or
redirect the output of a child process into a text editor.

Something like
      sbtn.signal_connect("pressed") {
         system('ls')
         }

... launch the command 'ls' but is not portable and

If you just want to get a list of files in a directory, Ruby
provides the portable Dir#entries method.

I don't know how to
redirect the output into a gtk text editor, not in the original
terminal window.

I'm sure the gtk text editor has some #append or #insert method
which lets you add text to it. Use that.

Something like
      sbtn.signal_connect("pressed") {
         lsproc = IO.popen('ls')
         p Process.waitpid(lsproc.pid)
         p $?
         }
... is portable, but still does not redirect the output.

IO.popen('ls') do |f|
  puts f.read
end

If you want to "pipe" some data to the subprocess:

request = "i want ice cream!"

IO.popen('cat', 'r+') do |f|
  f.write request
  f.close_write

  response = f.read
  puts "cat said: #{response}"
end

Hi,

···

2006/10/8, Mickael Faivre-Macon <faivrem@gmail.com>:

Hi,

Using ruby-gnome2 (gtk) I'd like to embed a terminal in a window, or
redirect the output of a child process into a text editor.

What about Ruby/VTE? Ruby/VTE is included in Ruby-GNOME2 since
0.15.0.

Thanks,
--
kou