Logging stdout/stderr/stdin of an spawn process (Open4::spawn)

E

Ed Hames

Hi dear rubyists,

I need to log all the input (typed by the user) and the stdout/stderr
of a process. The #script method below should behave pretty much like
the Unix script application. This way, my application can issue
several commands, show their output to the user an let them whatever
is needed.

def script cmd, log
# prepare $stdin to save its content into log
# prepare $stdout to save its content into log
# prepare $stderr to save its content into log
status = Open4::spawn cmd, 'stdin' => $stdin, 'stdout' =>
$stdout, 'stderr' => $stderr
end

I've seen some implementations of a #tee function or Tee class, but
they don't seem to work with spawn. What would you suggest?

Thanks in advance,
Ed
 

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

Similar Threads


Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top