# Capture stdout and stderr from another process

**URL:** <https://www.ruby-forum.com/t/capture-stdout-and-stderr-from-another-process/127588>\
**Category:** Ruby\
**Created:** [January 30, 2008, 4:16pm UTC](https://www.ruby-forum.com/t/capture-stdout-and-stderr-from-another-process/127588 "2008-01-30T16:16:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pazu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e9c0ed/32.png) [@pazu](https://www.ruby-forum.com/u/pazu)\
**Post date:** [January 30, 2008, 4:16pm UTC](https://www.ruby-forum.com/t/capture-stdout-and-stderr-from-another-process/127588/1 "2008-01-30T16:16:53Z")

</div>

I want to

1. Start another (lengthy) process/command from a ruby script
2. Capture whatever that process is writing to stdout and stderr  
separately
3. At the samt time give feedback to the console on what is happening  
(ie I don’t want all information at the end, I want it as it is  
available, maybe to a callback or so…)
4. Do it on windows

Possible? How if so?

I’ve tried with back ticks but that only captures stdout and I get all  
info at the end (violates both 2 and 3 above). I’ve also looked at  
systemu but that seems to violate 3 although I do get 2 (I may be  
wrong about 3 though).

Best regards,

Marcus

---

<div class="post-metadata">

**Author:** ![pazu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e9c0ed/32.png) [@pazu](https://www.ruby-forum.com/u/pazu)\
**Post date:** [January 30, 2008, 9:05pm UTC](https://www.ruby-forum.com/t/capture-stdout-and-stderr-from-another-process/127588/2 "2008-01-30T21:05:55Z")

</div>

On Jan 30, 10:15 am, Marcus B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want to
> 
> 1. Start another (lengthy) process/command from a ruby script
> 2. Capture whatever that process is writing to stdout and stderr separately
> 3. At the samt time give feedback to the console on what is happening  
> (ie I don’t want all information at the end, I want it as it is  
> available, maybe to a callback or so…)
> 4. Do it on windows
> 
> Possible? How if so?

Look at Win32-Process ([http://rubyforge.org/docman/view.php/85/1720/](http://rubyforge.org/docman/view.php/85/1720/)  
Process.html)  
or win32-open3 ([http://rubyforge.org/docman/view.php/85/128/open3.txt](http://rubyforge.org/docman/view.php/85/128/open3.txt))
