[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Detecting rubyw

Nathaniel Talbott

11/17/2004 3:02:00 AM

Is there any way (on Windows) to detect if a script is running under
rubyw.exe, i.e. headless?

Thanks,


Nathaniel
Terralien, Inc.

<:((><



6 Answers

Lyndon Samson

11/17/2004 3:23:00 AM

0

Do you get an exception if you try puts? If so you could catch that.



On Wed, 17 Nov 2004 12:02:12 +0900, Nathaniel Talbott
<nathaniel@talbott.ws> wrote:
> Is there any way (on Windows) to detect if a script is running under
> rubyw.exe, i.e. headless?
>
> Thanks,
>
> Nathaniel
> Terralien, Inc.
>
> <:((><
>
>


Nathaniel Talbott

11/17/2004 2:28:00 PM

0

On Nov 16, 2004, at 22:22, Lyndon Samson wrote:

> Do you get an exception if you try puts? If so you could catch that.

Nope, no exception, and STDOUT.closed? returns false. Any other ideas?


Nathaniel
Terralien, Inc.

<:((><



nobu.nokada

11/17/2004 2:48:00 PM

0

Hi,

At Wed, 17 Nov 2004 12:02:12 +0900,
Nathaniel Talbott wrote in [ruby-talk:120600]:
> Is there any way (on Windows) to detect if a script is running under
> rubyw.exe, i.e. headless?

Can you open "CONIN$" and "CONOUT$" device files?

--
Nobu Nakada


Nathaniel Talbott

11/17/2004 2:58:00 PM

0

On Nov 17, 2004, at 09:48, nobu.nokada@softhome.net wrote:

> At Wed, 17 Nov 2004 12:02:12 +0900,
> Nathaniel Talbott wrote in [ruby-talk:120600]:
>> Is there any way (on Windows) to detect if a script is running under
>> rubyw.exe, i.e. headless?
>
> Can you open "CONIN$" and "CONOUT$" device files?

I don't know... how would I do that? I don't think I've ever opened a
device file on Windows.


Nathaniel
Terralien, Inc.

<:((><



nobu.nokada

11/17/2004 3:40:00 PM

0

Hi,

At Wed, 17 Nov 2004 23:57:52 +0900,
Nathaniel Talbott wrote in [ruby-talk:120639]:
> >> Is there any way (on Windows) to detect if a script is running under
> >> rubyw.exe, i.e. headless?
> >
> > Can you open "CONIN$" and "CONOUT$" device files?
>
> I don't know... how would I do that? I don't think I've ever opened a
> device file on Windows.

Just open as well as ordinary files.

begin
open("CONIN$") {}
open("CONOUT$", "w") {}
have_console = true
rescue SystemCallError
have_console = false
end

--
Nobu Nakada


Nathaniel Talbott

11/17/2004 3:48:00 PM

0

On Nov 17, 2004, at 10:39, nobu.nokada@softhome.net wrote:

> Nathaniel Talbott wrote in [ruby-talk:120639]:
>>>> Is there any way (on Windows) to detect if a script is running under
>>>> rubyw.exe, i.e. headless?
>>>
>>> Can you open "CONIN$" and "CONOUT$" device files?
>>
>> I don't know... how would I do that? I don't think I've ever opened a
>> device file on Windows.
>
> Just open as well as ordinary files.
>
> begin
> open("CONIN$") {}
> open("CONOUT$", "w") {}
> have_console = true
> rescue SystemCallError
> have_console = false
> end

Excellent! Works great. Thanks a ton, Nobu.


Nathaniel
Terralien, Inc.

<:((><