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

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.

···

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

On windows there are two ruby executables: ruby.exe and rubyw.exe. read about them here:

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.
--
Posted via http://www.ruby-forum.com/.

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.

--
Posted via http://www.ruby-forum.com/\.

Hi John,

no harm meant indeed.

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

···

Am Dienstag, 10. Feb 2009, 08:32:14 +0900 schrieb Raphael Clancy:

--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de

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.

···

--
Posted via http://www.ruby-forum.com/\.

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 )

···

--
Posted via http://www.ruby-forum.com/\.