Forum: Ruby New to Ruby. Why does the command line pop up an then go awa

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.
6e696a5e016115c898534fdab5564a14?d=identicon&s=25 John Budd (budder8818)
on 2009-02-09 02:18
When ever I run a code file .rb

The code,

puts "Hello"

I get the command prompt that flashes for a moment but does not stay up.


How do I fix this.
Ad97b577f331ae29ed90da5751f2e44f?d=identicon&s=25 Dan Diebolt (dandiebolt)
on 2009-02-09 02:26
(Received via mailing list)
On windows there are two ruby executables: ruby.exe and rubyw.exe. read
about them here:

http://rubyonwindows.blogspot.com/2007/05/faq-scri...

If you want to ruby console output run the script from a shell instead
of double clicking:

C:\Users\me\Desktop>ruby test.rb
Hello

or use irb:

C:\Users\me\Desktop>irb
irb(main):001:0> load "test.rb"
Hello
=> true
irb(main):002:0>

--- On Sun, 2/8/09, John Budd <budder8817@yahoo.com> wrote:
From: John Budd <budder8817@yahoo.com>
Subject: New to Ruby. Why does the command line pop up an then go awa
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Date: Sunday, February 8, 2009, 8:17 PM

When ever I run a code file .rb

The code,

puts "Hello"

I get the command prompt that flashes for a moment but does not stay up.


How do I fix this.
Ed280b073cbe589e18e9f763e998cfdf?d=identicon&s=25 Raphael Clancy (puffer_ape)
on 2009-02-10 00:33
This is not as correct as the other approaches, but you can also end
your code with "getc" then the program will pause until you press enter.

John Budd wrote:
> When ever I run a code file .rb
>
> The code,
>
> puts "Hello"
>
> I get the command prompt that flashes for a moment but does not stay up.
>
>
> How do I fix this.
C06869c119472a139eb163b72040b0db?d=identicon&s=25 Bertram Scharpf (Guest)
on 2009-02-10 04:32
(Received via mailing list)
Hi John,

no harm meant indeed.

Am Dienstag, 10. Feb 2009, 08:32:14 +0900 schrieb Raphael Clancy:
> John Budd wrote:
> > When ever I run a code file .rb
> > The code,
> >
> > puts "Hello"
> >
> > I get the command prompt that flashes for a moment but does not stay up.
>
> This is not as correct as the other approaches, but you can also end
> your code with "getc" then the program will pause until you press enter.
                                                                    ^^^^^

Unless you tweak "termios". What cannot be done on Windows...

Did ever anyone count the unnecessary and dulling questions
that arise by just running that wicked OS?

Sorry, sorry, sorry. I cannot resist posting the truism. A score
of times I refrained.

Bertram
54404bcac0f45bf1c8e8b827cd9bb709?d=identicon&s=25 7stud -- (7stud)
on 2009-02-10 06:05
See edits:

Dan Diebolt wrote:
>
> If you want to [see] ruby console output[,] [then] run the script from a shell instead
> of double clicking:
>

Essentially, your program does what you tell it:  open a console window,
run the program, close the console window.  Because running your program
takes only a microsecond, you see the console flash open and shut.
Ed280b073cbe589e18e9f763e998cfdf?d=identicon&s=25 Raphael Clancy (puffer_ape)
on 2009-02-13 20:33
Raphael Clancy wrote:
> This is not as correct as the other approaches, but you can also end
> your code with "getc" then the program will pause until you press enter.
>
> John Budd wrote:
>> When ever I run a code file .rb
>>
>> The code,
>>
>> puts "Hello"
>>
>> I get the command prompt that flashes for a moment but does not stay up.
>>
>>
>> How do I fix this.

Sigh... "getc" is sorta deprecated. Use "gets" or "STDIN.getc" if you
get a warning with "getc". (I guess it was even less correct than I
thought ;-D )
This topic is locked and can not be replied to.