[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

STDIN, OUT, ERR and $stdin, out, err - Differences?

Terry Cooper

6/6/2009 1:14:00 AM

Can anyone explain what's happening here?

print $stdin.fileno => 0
print $stdout.fileno => 0
print $sterr.fileno => 0

print STDIN.fileno => 0
print STDOUT.fileno => 1
print STDERR.fileno => 2

print STDOUT.object_id => 21673330
print $stdout.object_id => 21673330

I get the same results in and out of eclipse and with irb

ruby 1.8.6, XP

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

13 Answers

Jeff Moore

6/6/2009 10:44:00 PM

0

Terry Cooper wrote:
> Can anyone explain what's happening here?
>
> print $stdin.fileno => 0
> print $stdout.fileno => 0
> print $sterr.fileno => 0
>
> print STDIN.fileno => 0
> print STDOUT.fileno => 1
> print STDERR.fileno => 2
>
> print STDOUT.object_id => 21673330
> print $stdout.object_id => 21673330
>
> I get the same results in and out of eclipse and with irb
>
> ruby 1.8.6, XP
>
> Many thanks.

Simply, STDIN, STDOUT, STDERR are CONSTANTS and
$stdin, $stdout, and $stderr are global variables.

They are the same initially but the variables can
be re-assigned.
--
Posted via http://www.ruby-....

Luis Lavena

6/7/2009 12:12:00 AM

0

On Jun 5, 10:14 pm, Terry Cooper <terence_coo...@hotmail.com> wrote:
> Can anyone explain what's happening here?
>
> print $stdin.fileno  => 0
> print $stdout.fileno => 0
> print $sterr.fileno  => 0
>
> print STDIN.fileno  => 0
> print STDOUT.fileno => 1
> print STDERR.fileno => 2
>
> print STDOUT.object_id     => 21673330
> print $stdout.object_id    => 21673330
>
> I get the same results in and out of eclipse and with irb
>
> ruby 1.8.6, XP
>
> Many thanks.

Differences between $stdout and STDOUT:

http://blog.segment7.net/articles/2006/08/17/stdout...

The bottom line is don't mess with STDOUT and use $stdout instead.

Regards,
--
Luis Lavena

Brian Candler

6/7/2009 5:35:00 PM

0

Terry Cooper wrote:
> Can anyone explain what's happening here?
>
> print $stdin.fileno => 0
> print $stdout.fileno => 0
> print $sterr.fileno => 0

Copy-paste error? The third line is clearly a typo for $stderr, and
under Linux at least these give 0, 1, 2 respectively.
--
Posted via http://www.ruby-....

Janos Sebok

6/8/2009 8:00:00 AM

0

On Sun, Jun 7, 2009 at 7:34 PM, Brian Candler <b.candler@pobox.com> wrote:

>
> Copy-paste error? The third line is clearly a typo for $stderr, and
> under Linux at least these give 0, 1, 2 respectively.
> --
> Posted via http://www.ruby-....
>
>
I can confirm this is true on WinXP, Ruby 1.8.7 and 1.9.1

--=20
=DCdv,
Sebi

Brian Candler

6/8/2009 12:40:00 PM

0

Janos Sebok wrote:
> On Sun, Jun 7, 2009 at 7:34 PM, Brian Candler <b.candler@pobox.com>
> wrote:
>
>>
>> Copy-paste error? The third line is clearly a typo for $stderr, and
>> under Linux at least these give 0, 1, 2 respectively.
>
> I can confirm this is true on WinXP, Ruby 1.8.7 and 1.9.1

That makes no sense. The OP said that $stdout.fileno != STDOUT.fileno,
and yet $stdout.object_id == STDOUT.object_id

It can't be the same object, but respond to the same method differently.

What do you get from this? Run it as a standalone ruby script, not
within irb, to eliminate irb as the source of the problem.

puts STDOUT.fileno
puts $stdout.fileno
puts STDOUT.inspect
puts $stdout.inspect
# and repeat for STDERR/$stderr
--
Posted via http://www.ruby-....

Brian Candler

6/8/2009 12:50:00 PM

0

Brian Candler wrote:
> Janos Sebok wrote:
>> On Sun, Jun 7, 2009 at 7:34 PM, Brian Candler <b.candler@pobox.com>
>> wrote:
>>
>>>
>>> Copy-paste error? The third line is clearly a typo for $stderr, and
>>> under Linux at least these give 0, 1, 2 respectively.
>>
>> I can confirm this is true on WinXP, Ruby 1.8.7 and 1.9.1

Maybe I misunderstood, and you were confirming my interpretation to be
true, not the OP's :-)

Anyway I've just booted a laptop into XP, and done this:

C:\>ruby
puts STDOUT.fileno
puts $stdout.fileno
puts STDOUT.inspect
puts $stdout.inspect
puts STDERR.fileno
puts $stderr.fileno
puts STDERR.inspect
puts $stderr.inspect
^Z
1
1
#<IO:0x2846af0>
#<IO:0x2846af0>
2
2
#<IO:0x2846adc>
#<IO:0x2846adc>

C:\>ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

This version of Ruby came from the 'one-click installer' Ruby-186-26

And FWIW, I get the same in irb too.

HTH,

Brian.


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

Janos Sebok

6/9/2009 5:48:00 AM

0

>>Maybe I misunderstood, and you were confirming my interpretation to be
>>true, not the OP's :-)

;) Yes, I meant you were right; it's working as intended (0, 1, 2 ) on
windows.


On Mon, Jun 8, 2009 at 2:50 PM, Brian Candler <b.candler@pobox.com> wrote:

> Brian Candler wrote:
> > Janos Sebok wrote:
> >> On Sun, Jun 7, 2009 at 7:34 PM, Brian Candler <b.candler@pobox.com>
> >> wrote:
> >>
> >>>
> >>> Copy-paste error? The third line is clearly a typo for $stderr, and
> >>> under Linux at least these give 0, 1, 2 respectively.
> >>
> >> I can confirm this is true on WinXP, Ruby 1.8.7 and 1.9.1
>
>
> Anyway I've just booted a laptop into XP, and done this:
>
> C:\>ruby
> puts STDOUT.fileno
> puts $stdout.fileno
> puts STDOUT.inspect
> puts $stdout.inspect
> puts STDERR.fileno
> puts $stderr.fileno
> puts STDERR.inspect
> puts $stderr.inspect
> ^Z
> 1
> 1
> #<IO:0x2846af0>
> #<IO:0x2846af0>
> 2
> 2
> #<IO:0x2846adc>
> #<IO:0x2846adc>
>
> C:\>ruby -v
> ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
>
> This version of Ruby came from the 'one-click installer' Ruby-186-26
>
> And FWIW, I get the same in irb too.
>
> HTH,
>
> Brian.
>
>
> --
> Posted via http://www.ruby-....
>
>


--=20
=DCdv,
Sebi

stangbat

2/18/2011 1:47:00 AM

0


Looks like they are out of stock right now, but I bought the opaque
green targets from Bay Area Amusements and they were a perfect match for
my other targets. They were Item No. TG-12912-G.


--
stangbat
This USENET post sent from http://rgpa...

luther r

2/18/2011 1:50:00 AM

0

On 2/17/11 7:39 PM, Drain Man wrote:
> Thanks LTG...as always, you are the man.


The ones Mike at Mad Amusements sells are pretty much indistinguishable
from the originals. They're probably the same as the ones Lloyd pointed out.

toyboy6

2/18/2011 2:12:00 AM

0

I think you are looking for part number A-18018-21.

Looks like you can get them all over:

http://www.pinball-signs.com/HTML/STANDTAR...
http://www.pbresource.com/pf...
http://www.marcospecialties.com/product.asp?ic=A%2D...
http://www.littleshopofgames.com/Game...
http://mad-amusements.com/product.php?id_p...
http://www.actionpinball.com/pa...

The opaque are solid and should be fairly close in color. But if you
are really worried about it - buy 2 of them and replace both of the
targets on the RH side.

Scott