Ruby on Windows.

H

Henry Savr

I have two problems with my Ruby for Windows (1.8.4):

1. When I double-click on a file with .rb extention a DOS-like window
appears and dissapears immediately. I am not able to see results.

2. The Windows command (which should work as it's UNIX parent)

echo 'puts "Hello"' | ruby

(the command is borrowed from "Programming Ruby" 2nd edition p.318)

does not show any results:
=============
C:\Documents and Settings\Admin>echo 'puts "Hello"' | ruby

C:\Documents and Settings\Admin>
==============

Sure, it works with Linux.

How to tune my Windows XT Pro to be more Ruby friendly?

Thank you
Henry
 
J

John Miller

C:\Documents and Settings\Admin>echo 'puts "Hello"' | ruby

C:\Documents and Settings\Admin>

Look at the output of the echo command:

C:\>echo 'puts "Hello"'
'puts "Hello"'

The windows shell includes the single-quote whaere as bash does not.

try:

C:\>echo puts "Hello" | ruby
Hello
C:\>

As for the problem with the DOS box. Adding a requireing input at the
end of the program is one (poor) solution, as is using a cmd shell. I
hope someone has a better one

J.F. Miller
 
S

Sander Land

I have two problems with my Ruby for Windows (1.8.4):

1. When I double-click on a file with .rb extention a DOS-like window
appears and dissapears immediately. I am not able to see results.
You need to open a command prompt and run it from there. Try
installing a shell extension with a "open command prompt here" option
if you need this a lot.
2. The Windows command (which should work as it's UNIX parent)

echo 'puts "Hello"' | ruby
echo 'puts "aa"'
'puts "aa"'

The cmd echo apparently includes the quotes, resulting in a string
which is valid ruby code but doesn't output anything.
Try:
echo puts "aa" | ruby aa
ruby -e 'puts "aa"'
aa
 
C

Cory Chamblin

I have two problems with my Ruby for Windows (1.8.4):

1. When I double-click on a file with .rb extention a DOS-like window
appears and dissapears immediately. I am not able to see results.

Just write a little batch file:

@echo off
ruby %1
pause

Save it in your Ruby bin directory (I called mine rdos.bat), and
associate rb files with it. HTH.

Cheers,
Cory
 
J

Jan Svitok

I have two problems with my Ruby for Windows (1.8.4):

1. When I double-click on a file with .rb extention a DOS-like window
appears and dissapears immediately. I am not able to see results.

Start your program from the shell (cmd/DOS window). Then the window
will not go away, and you'll be able to see the result. I suppose you
did it that way in the next question, so I'm afraid I'm stating the
obvious ;-)

If you want to see the results when doubleclicked the file, add
something that will pause your program at the end (e.g. gets, sleep)
or write your result to a file.

And in case you'd not want to see even the DOS window, rename your
file to .rbw ;-)
 
C

Cristi BALAN

I have two problems with my Ruby for Windows (1.8.4):

1. When I double-click on a file with .rb extention a DOS-like window
appears and dissapears immediately. I am not able to see results.
In explorer, if you go to folder options, and click advanced for the
rb extension, you will see that it uses the following to open a .rb
file:
"c:\ruby\bin\ruby.exe" "%1" %*

You can get the windows to stick around if you change that to:
cmd.exe /K "c:\ruby\bin\ruby.exe %1 %*"

I wouldn't recommend it tho, since you won't be able to accept files
with spaces and justhaving the windows stick around is nasty. Better
run your script from a cmd instance.
Thank you
Henry

HTH
 
R

Ryan Eibling

Cory said:
Just write a little batch file:

@echo off
ruby %1
pause

Save it in your Ruby bin directory (I called mine rdos.bat), and
associate rb files with it. HTH.

Cheers,
Cory

Hey, that's a good idea. I didn't ask the question, but thanks!
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top