Forum: Ruby Pipes and STDERR

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B4c5e9c7d51188f1f7e8ba79ec80ddf9?d=identicon&s=25 James S. (jmdjmsmith)
on 2007-02-16 11:39
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?
Robert Klemme (Guest)
on 2007-02-16 13:50
(Received via mailing list)
On 16.02.2007 11:39, James Smith 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
B4c5e9c7d51188f1f7e8ba79ec80ddf9?d=identicon&s=25 James S. (jmdjmsmith)
on 2007-02-16 16:29
>
> 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
Robert Klemme (Guest)
on 2007-02-16 18:15
(Received via mailing list)
On 16.02.2007 16:29, James Smith 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

Regards

  robert
This topic is locked and can not be replied to.