[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby on Windows.

Henry Savr

9/8/2006 6:30:00 PM

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



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

6 Answers

John Miller

9/8/2006 6:42:00 PM

0


> 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

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

Sander Land

9/8/2006 6:48:00 PM

0

On 9/8/06, Henry Savr <hsavr@yahoo.com> wrote:
> 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

Cory Chamblin

9/8/2006 6:52:00 PM

0

On 9/8/06, Henry Savr <hsavr@yahoo.com> wrote:
> 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

Jano Svitok

9/8/2006 6:55:00 PM

0

On 9/8/06, Henry Savr <hsavr@yahoo.com> wrote:
> 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 ;-)

Cristi Balan

9/8/2006 7:07:00 PM

0

On 9/8/06, Henry Savr <hsavr@yahoo.com> wrote:
> 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

--
Cristi BALAN
http://ev...
http://evil...

Ryan Eibling

9/8/2006 11:26:00 PM

0

Cory Chamblin wrote:
> On 9/8/06, Henry Savr <hsavr@yahoo.com> wrote:
>> 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

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