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.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFFKY1OmV9O7RYnKMcRAn05AKCP1Qnc4TTVvIYcKtWrVC8RKMZFOQCfYWAk
Ln8UdA+jfmrRfawr1VYoPgc=
=EHSf
-----END PGP SIGNATURE-----

Hi,

2006/10/8, Mickael Faivre-Macon [email protected]:

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,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs