interactive shell on windows

P

py

I downloaded and installed Ruby via the One-Click installer, version
1.8.2-15. So I open a command prompt (on windows xp) and type "ruby".

After typing "ruby" i type,
puts "Hello world!"

....but I dont see Hello world! printed out. Am I missing something, am
I doing something wrong? I happened to try pressing Ctrl+Z to exit
ruby (..forgive me I am coming from Python)...and then I saw "hello
world!" printed out....but that doesn't seem right.

Thanks
 
C

Curt Hibbs

------=_Part_7419_32447776.1132163453774
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Instead of typing "ruby", type "irb" (stands for interactive ruby).

Curt

I downloaded and installed Ruby via the One-Click installer, version
1.8.2-15. So I open a command prompt (on windows xp) and type "ruby".

After typing "ruby" i type,
puts "Hello world!"

....but I dont see Hello world! printed out. Am I missing something, am
I doing something wrong? I happened to try pressing Ctrl+Z to exit
ruby (..forgive me I am coming from Python)...and then I saw "hello
world!" printed out....but that doesn't seem right.

Thanks

------=_Part_7419_32447776.1132163453774--
 
P

py

Curt said:
Instead of typing "ruby", type "irb" (stands for interactive ruby).

Thanks! Apparently the "Programming Ruby" .chm (help) file that comes
with ruby needs to be fixed. It says to use "ruby" :)

thanks!
 
M

Matthew Desmarais

py said:
Curt Hibbs wrote:



Thanks! Apparently the "Programming Ruby" .chm (help) file that comes
with ruby needs to be fixed. It says to use "ruby" :)

thanks!
No kidding! Where did it say that?
 
P

py

Matthew said:
No kidding! Where did it say that?

Well for the One-Click installer for Windows, version 1.8.2-15 includes
ProgrammingRuby.chm (under the ruby directory).

In that help file look under Preface/Running Ruby/Interactive Ruby
....copied/pasted below...

[excerpt]
"Interactive Ruby

The easiest way to run Ruby interactively is simply to type ``ruby'' at
the shell prompt.

% ruby
puts "Hello, world!"
^D
Hello, world!
[/excerpt]

See :)
 
C

Curt Hibbs

------=_Part_7679_26187208.1132165337026
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Matthew said:
No kidding! Where did it say that?

Well for the One-Click installer for Windows, version 1.8.2-15 includes
ProgrammingRuby.chm (under the ruby directory).

In that help file look under Preface/Running Ruby/Interactive Ruby
....copied/pasted below...

[excerpt]
"Interactive Ruby

The easiest way to run Ruby interactively is simply to type ``ruby'' at
the shell prompt.

% ruby
puts "Hello, world!"
^D
Hello, world!
[/excerpt]

See :)


I see what's going on here. Ruby with no args reads from the standard input
(in this case the terminal) and runs whatever it gets as soon as the input
stream terminates, which is the "^D", and not your enter key. If you were t=
o
use this technique, you would have to tye "ruby" again to execute something
else.

IRB executes and the enter key and then waits for another line to execute.
This is, obviously, much more convenient! :)

Curt

------=_Part_7679_26187208.1132165337026--
 
H

Hugh Sasse

Matthew said:
No kidding! Where did it say that?

Well for the One-Click installer for Windows, version 1.8.2-15 includes
ProgrammingRuby.chm (under the ruby directory).

In that help file look under Preface/Running Ruby/Interactive Ruby
....copied/pasted below...

[excerpt]
"Interactive Ruby

The easiest way to run Ruby interactively is simply to type ``ruby'' at
the shell prompt.

% ruby
puts "Hello, world!"
^D
Hello, world!
[/excerpt]

See :)

But you said:


After typing "ruby" i type,
puts "Hello world!"

....but I dont see Hello world! printed out.

So did you type the end-of-file mark for your system (which is what
ctrl-d means on unix)?

Then read 7 short paragraphs and you meet IRB, which has it's own
champter in the contents.
Hugh
 
M

Matthew Desmarais

Curt said:
Matthew Desmarais wrote:

No kidding! Where did it say that?
Well for the One-Click installer for Windows, version 1.8.2-15 includes
ProgrammingRuby.chm (under the ruby directory).

In that help file look under Preface/Running Ruby/Interactive Ruby
....copied/pasted below...

[excerpt]
"Interactive Ruby

The easiest way to run Ruby interactively is simply to type ``ruby'' at
the shell prompt.

% ruby
puts "Hello, world!"
^D
Hello, world!
[/excerpt]

See :)


I see what's going on here. Ruby with no args reads from the standard input
(in this case the terminal) and runs whatever it gets as soon as the input
stream terminates, which is the "^D", and not your enter key. If you were to
use this technique, you would have to tye "ruby" again to execute something
else.

IRB executes and the enter key and then waits for another line to execute.
This is, obviously, much more convenient! :)

Curt
Yup. I was gonna respond with this as well, but I'll just second Curt
instead.

Get to know irb if you're experimenting with Ruby. It's just the kind
of thing
that a person coming from Python expects to see when they run ruby with
no arguments.

Well, almost. irb doesn't play dumb when you want to quit. ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top