# Pipes and STDERR

**URL:** <https://www.ruby-forum.com/t/pipes-and-stderr/85792>\
**Category:** Ruby\
**Created:** [February 16, 2007, 11:39am UTC](https://www.ruby-forum.com/t/pipes-and-stderr/85792 "2007-02-16T11:39:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jspencer78](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jspencer78](https://www.ruby-forum.com/u/jspencer78)\
**Post date:** [February 16, 2007, 11:39am UTC](https://www.ruby-forum.com/t/pipes-and-stderr/85792/1 "2007-02-16T11:39:02Z")

</div>

Hello everyone,

I would like to be able to assign my pipe to a variable, whilst still  
being able to capture STDERR; i’m sure this is possible but can’t think  
how to do it…

This is the code for the pipe:

@pipe = IO.popen(“ruby userFile/file.rb”, “r+”)

I am on windows and have tried to use the systemu library to no avail…

any ideas?

---

<div class="post-metadata">

**Author:** ![jspencer78](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jspencer78](https://www.ruby-forum.com/u/jspencer78)\
**Post date:** [February 16, 2007, 1:50pm UTC](https://www.ruby-forum.com/t/pipes-and-stderr/85792/2 "2007-02-16T13:50:39Z")

</div>

On 16.02.2007 11:39, James S. wrote:

> I would like to be able to assign my pipe to a variable, whilst still  
> being able to capture STDERR; i’m sure this is possible but can’t think  
> how to do it…

What exactly do you mean? Why is the pipe and stderr related? Are you  
talking about stderr of the Ruby process or of some child process?

Regards

robert

---

<div class="post-metadata">

**Author:** ![jspencer78](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jspencer78](https://www.ruby-forum.com/u/jspencer78)\
**Post date:** [February 16, 2007, 4:29pm UTC](https://www.ruby-forum.com/t/pipes-and-stderr/85792/3 "2007-02-16T16:29:17Z")

</div>

> What exactly do you mean? Why is the pipe and stderr related? Are you  
> talking about stderr of the Ruby process or of some child process?

Sorry, not very well explained… i need to capture stderr of the ruby  
process and write it into the pipe

---

<div class="post-metadata">

**Author:** ![jspencer78](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jspencer78](https://www.ruby-forum.com/u/jspencer78)\
**Post date:** [February 16, 2007, 6:15pm UTC](https://www.ruby-forum.com/t/pipes-and-stderr/85792/4 "2007-02-16T18:15:37Z")

</div>

On 16.02.2007 16:29, James S. wrote:

> > What exactly do you mean? Why is the pipe and stderr related? Are you  
> > talking about stderr of the Ruby process or of some child process?
> 
> Sorry, not very well explained… i need to capture stderr of the ruby  
> process and write it into the pipe

Ah! Then I’d try this:

STDERR.reopen(pipe)

[http://www.ruby-doc.org/core/classes/IO.html#M002301](http://www.ruby-doc.org/core/classes/IO.html#M002301)

Regards

robert
