[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

stderr capture on Windows

Sard Aukary

8/13/2006 5:26:00 PM

Is it possible to capture stderr on Windows?

Backtick seems to ignore it, and

require "open3"
stdin, stdout, stderr = Open3.popen3('dir')

gives me

"the fork() function is unimplemented on this machine
(NotImplementedError)"

--
Posted via http://www.ruby-....

7 Answers

Anatol Pomozov

8/13/2006 7:53:00 PM

0

Sard Aukary wrote:
> Is it possible to capture stderr on Windows?
>
> Backtick seems to ignore it, and
>
> require "open3"
> stdin, stdout, stderr = Open3.popen3('dir')
>
> gives me
>
> "the fork() function is unimplemented on this machine
> (NotImplementedError)"

See solution here
http://blog.pomozov.info/posts/capturing-stderr-on...

--
Posted via http://www.ruby-....

Sard Aukary

8/13/2006 7:59:00 PM

0

Anatol Pomozov wrote:
> See solution here
> http://blog.pomozov.info/posts/capturing-stderr-on...

Well that gives me another cryptic error

"The handle could not be duplicated during redirection of handle 1" :D

--
Posted via http://www.ruby-....

Jeff Schwab

8/13/2006 8:02:00 PM

0

Sard Aukary wrote:
> Anatol Pomozov wrote:
>> See solution here
>> http://blog.pomozov.info/posts/capturing-stderr-on...
>
> Well that gives me another cryptic error
>
> "The handle could not be duplicated during redirection of handle 1" :D

Does this program give you the same error?

cmd = 'dir'
ARGV.each {|arg|
line_no = 0
`#{cmd} #{arg} 2>&1|more`.each {|line|
puts "#{cmd}:#{line_no += 1}:#{line}"
}
}

Jeff Schwab

8/13/2006 8:04:00 PM

0

Jeffrey Schwab wrote:
> Sard Aukary wrote:
>> Anatol Pomozov wrote:
>>> See solution here
>>> http://blog.pomozov.info/posts/capturing-stderr-on...
>>
>> Well that gives me another cryptic error
>>
>> "The handle could not be duplicated during redirection of handle 1" :D
>
> Does this program give you the same error?
>
> cmd = 'dir'
> ARGV.each {|arg|
> line_no = 0
> `#{cmd} #{arg} 2>&1|more`.each {|line|
> puts "#{cmd}:#{line_no += 1}:#{line}"
> }
> }

Actually, skip all that and just try this:

`dir 2>&1`.each {|line| puts line }

Anatol Pomozov

8/13/2006 8:09:00 PM

0

Sard Aukary wrote:
> Anatol Pomozov wrote:
>> See solution here
>> http://blog.pomozov.info/posts/capturing-stderr-on...
>
> Well that gives me another cryptic error
>
> "The handle could not be duplicated during redirection of handle 1" :D

Try to put following line to separate script and run

puts `dir 2>&1`

what do you see?

If everything is OK then problem in you main script. Try to check that
you do not copy or replace STDOUT.

--
Posted via http://www.ruby-....

Bill Kelly

8/13/2006 8:44:00 PM

0

From: "Sard Aukary" <sardaukary@yahoo.co.uk>
>
> Is it possible to capture stderr on Windows?
>
> Backtick seems to ignore it, and
>
> require "open3"
> stdin, stdout, stderr = Open3.popen3('dir')
>
> gives me
>
> "the fork() function is unimplemented on this machine
> (NotImplementedError)"

http://popen4.ruby...

or

gem install POpen4

It should present several possible versions to install. If your
windows ruby was installed using the 1.8.4 one-click installer,
you probably want the "win32-1.8.4-VC6" version.


Regards,

Bill



Sard Aukary

8/14/2006 7:49:00 PM

0

Anatol Pomozov wrote:
> puts `dir 2>&1`
>
> what do you see?
>
> If everything is OK then problem in you main script. Try to check that
> you do not copy or replace STDOUT.

Yes it was my script that works now.

Thanks for the help.


--
Posted via http://www.ruby-....