Hi, all.
The program I want to execute as a external program in ruby is using a
write system call.
When I use IO.popen or IO.pipe, there is no output because of the
external program didn’t flush it’s output. (but, when I executed it in
shell, normally it shows up outputs).
But, when I use PTY.spawn(), the output is generated.
what’s the differences between them??
On Apr 19, 2009, at 9:17 PM, Jun Y. Kim wrote:
The program I want to execute as a external program in ruby is using
a write system call.
When I use IO.popen or IO.pipe, there is no output because of the
external program didn’t flush it’s output. (but, when I executed it
in shell, normally it shows up outputs).
Try doing it this way:
output = IO.popen(“command here”, “w+”) { |cmd|
cmd.close_write
cmd.read
}
A lot of times, closing the writing stream will trigger the output.
Hope that helps.
James Edward G. II
Actually, I didn’t work normally for my case.
after getting a read io pipe, my program is waiting some events by
using select.
but it always returns nil because the external program did
nothing(didn’t flush something)
thanks for response.
-
- 20, ì˜¤ì „ 11:43, James G. 작성:
2009/4/20 Jun Y. Kim [email protected]:
Actually, I didn’t work normally for my case.
after getting a read io pipe, my program is waiting some events by using
select.
but it always returns nil because the external program did nothing(didn’t
flush something)
thanks for response.
As I said in my previous posting many programs ensure complete lines
are sent to the output channel if it is a terminal but they do not if
the output is a file or pipe because it is assumed that there
immediate delivery does not matter and hence not flushing individual
lines yields more throughput.
Cheers
robert