ruby/GTK : Embedded terminal or redirecting process output

  • Thread starter Mickael Faivre-Macon
  • Start date
M

Mickael Faivre-Macon

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.
 
S

Suraj N. Kurapati

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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-----
 
K

Kouhei Sutou

Hi,


2006/10/8 said:
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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top