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.

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 B. [email protected] wrote:
From: John B. [email protected]
Subject: New to Ruby. Why does the command line pop up an then go awa
To: “ruby-talk ML” [email protected]
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.

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 B. 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.

Hi John,

no harm meant indeed.

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

John B. 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

Raphael C. 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 B. 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 )

See edits:

Dan D. 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.