From: Lawrence Oluyede Date: 2005-05-13T05:35:28+09:00 Subject: Get back data from a child (with exec) What I'm trying to do is to pass some data to a child process that execute an external process and get back data from this external process. --- PATH = "/usr/bin/highlight" ARGS = "-f -l -t 8 -S %s" LANG = "rb" rd, wr = IO.pipe if fork # parent rd.close $stdout.reopen(wr) wr.close fd = File.open("/usr/lib/ruby/1.8/thread.rb") str = fd.read $stdout.write str else # child wr.close $stdin.reopen(rd) rd.close params = ARGS % LANG cmd = "%s %s" % [PATH, params] exec cmd end --- This works but child puts returned data to the standard output (to the linux shell). I'd like to get back that output in the parent. How can I do it? -- Lawrence http://www.oluyede.org/blog