Is there a simple way to spawn an external program, feed its stdin, and
get its stdout?
The problem with popen is, if I want to feed a few MB’s of input to it,
then it hangs (I suspect that its stdout IO buffer is full) before I
could read out its stdout on the next line. So, the following do not
work:
require ‘open3’
Open3.popen3(“externalfilter”) { |sin,sout,serr|
sin.write(verybigstring)
result = sout.read
}
···
On Sunday 18 January 2004 5:39 am, Ferenc Engard wrote:
Hi all,
Is there a simple way to spawn an external program, feed its stdin,
and get its stdout?
The problem with popen is, if I want to feed a few MB’s of input to
it, then it hangs (I suspect that its stdout IO buffer is full)
before I could read out its stdout on the next line. So, the
following do not work:
“Ferenc Engard” ferenc@engard.hu schrieb im Newsbeitrag
news:400A7E96.F52F09C6@engard.hu…
Hi all,
Is there a simple way to spawn an external program, feed its stdin, and
get its stdout?
The problem with popen is, if I want to feed a few MB’s of input to it,
then it hangs (I suspect that its stdout IO buffer is full) before I
could read out its stdout on the next line. So, the following do not
work:
Date: Sun, 18 Jan 2004 21:39:41 +0900
From: Ferenc Engard ferenc@engard.hu
Newsgroups: comp.lang.ruby
Subject: running external process?
Hi all,
Is there a simple way to spawn an external program, feed its stdin, and
get its stdout?
The problem with popen is, if I want to feed a few MB’s of input to it,
then it hangs (I suspect that its stdout IO buffer is full) before I
could read out its stdout on the next line. So, the following do not
work:
io=IO.popen(“externalfilter”)
io.write(verybigstring)
io.close # the program is still reading it’s stding here
result=io.read
Thanks,
Ferenc
-a
···
On Sun, 18 Jan 2004, Ferenc Engard wrote:
ATTN: please update your address books with address below!
The difference between art and science is that science is what we
understand well enough to explain to a computer.
Art is everything else.
– Donald Knuth, “Discover”
/bin/sh -c ‘for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done’
===============================================================================
On Sunday 18 January 2004 8:26 am, Wesley J Landaker wrote:
On Sunday 18 January 2004 5:39 am, Ferenc Engard wrote:
Hi all,
Is there a simple way to spawn an external program, feed its stdin,
and get its stdout?
The problem with popen is, if I want to feed a few MB’s of input to
it, then it hangs (I suspect that its stdout IO buffer is full)
before I could read out its stdout on the next line. So, the
following do not work:
The problem with popen is, if I want to feed a few MB’s of input to it,
then it hangs (I suspect that its stdout IO buffer is full) before I
could read out its stdout on the next line. So, the following do not
work: