.rb files in WIndows

Here’s a question for you.

When you double-click on a
.rb (or .rbw) file in Windows,
it associates it with Ruby and
runs it properly. Well and
good. (I think this trick is
accomplished by Andy’s installer?)

Now: How can I achieve this from
the command line? I.e., I want to
run foo.rb simply by typing its
name. (Yes, I spend a significant
amount of my Windows time at the
so-called DOS prompt.)

I think there’s a way. I think I
read about it once. But I can’t
find it now.

Thanks,
Hal Fulton

It’s possible with NT cmd.exe, not Win9x DOS Prompt
(Or maybe there is?)

···

On Sunday 14 July 2002 00:46, you wrote:

Here’s a question for you.

When you double-click on a
.rb (or .rbw) file in Windows,
it associates it with Ruby and
runs it properly. Well and
good. (I think this trick is
accomplished by Andy’s installer?)

Now: How can I achieve this from
the command line? I.e., I want to
run foo.rb simply by typing its
name. (Yes, I spend a significant
amount of my Windows time at the
so-called DOS prompt.)

I think there’s a way. I think I
read about it once. But I can’t
find it now.

Thanks,
Hal Fulton

Here’s half a solution: write foo.bat with “ruby foo.rb” in it. Type foo
:slight_smile:

···

Now: How can I achieve this from the command line? I.e., I want to run
foo.rb simply by typing its name. (Yes, I spend a significant amount
of my Windows time at the so-called DOS prompt.)

Hi Hal,

I don’t know whether you’re using cygwin / bash, but if you are,
adding the following line to the start of the source file works:

#!/cygdrive/c/ruby/bin/ruby -w

(Adjust appropriately, the -w is optional).

Unfortunately this is machine specific (but you could always write a
script to add/change/remove the line).

Cheers,
Gordon

···

On Sat, 13 Jul 2002 16:48:18 GMT, “Hal E. Fulton” hal9000@hypermetrics.com wrote:

Here’s a question for you.

When you double-click on a
rb (or .rbw) file in Windows,
it associates it with Ruby and
runs it properly. Well and
good. (I think this trick is
accomplished by Andy’s installer?)

Now: How can I achieve this from
the command line? I.e., I want to
run foo.rb simply by typing its
name. (Yes, I spend a significant
amount of my Windows time at the
so-called DOS prompt.)

I think there’s a way. I think I
read about it once. But I can’t
find it now.

Thanks,
Hal Fulton

Now: How can I achieve this from
the command line? I.e., I want to
run foo.rb simply by typing its
name. (Yes, I spend a significant
amount of my Windows time at the
so-called DOS prompt.)

I’ve never heard of such a mechanism, but if you find out, let the
list know.

···

=====

Use your computer to help find a cure for cancer: http://members.ud.com/projects/cancer/

Yahoo IM: michael_s_campbell


Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes

When you double-click on a
.rb (or .rbw) file in Windows,
it associates it with Ruby and
runs it properly. Well and
good. (I think this trick is
accomplished by Andy’s installer?)

It’s possible with NT cmd.exe, not Win9x DOS Prompt
(Or maybe there is?)

I think you’re right; I don’t know about XP, though.
See the ‘assoc’ and ‘ftype’ commands; on my Win2k box:

C:>assoc .rb
…rb=rbFile

C:>ftype rbfile
rbfile=“C:\ruby\bin\ruby.exe” “%1” %*

Sure, Xp inherited from NT and ‘NT cmd.exe’ tightly integrated
with native win32 syscall, while win9x DOS ‘command.com’ is
just a plain dos, it know nothing about win32 filetype assoc.

···

On Sunday 14 July 2002 02:00, you wrote:

I think you’re right; I don’t know about XP, though.
See the ‘assoc’ and ‘ftype’ commands; on my Win2k box:

C:>assoc .rb
…rb=rbFile

C:>ftype rbfile
rbfile=“C:\ruby\bin\ruby.exe” “%1” %*

If you add ‘.rb’ to the PATHEXT environment variable
(set PATHEXT=%PATHEXT%;.rb), you won’t even need to
type the extension of your ruby script. It will also
be found anywhere on the PATH.

Cheers,

Bernard.

Apparently correct. I can’t do this on Win98 as I
have neither of these executables.

One of these days I’ll have to crossgrade to XP,
or just give up and stick to Linux.

Thanks for the replies, Ariff, Bernard, Michael,
and Martin.

Cheers,
Hal Fulton

···

----- Original Message -----
From: “Ariff Abdullah” skywizard@time.net.my
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Saturday, July 13, 2002 1:28 PM
Subject: Re: .rb files in WIndows

On Sunday 14 July 2002 02:00, you wrote:

I think you’re right; I don’t know about XP, though.
See the ‘assoc’ and ‘ftype’ commands; on my Win2k box:

C:>assoc .rb
…rb=rbFile

C:>ftype rbfile
rbfile=“C:\ruby\bin\ruby.exe” “%1” %*

Sure, Xp inherited from NT and ‘NT cmd.exe’ tightly integrated
with native win32 syscall, while win9x DOS ‘command.com’ is
just a plain dos, it know nothing about win32 filetype assoc.

I was just hit by what I would call a spark of inspiration.
Try start.exe ? that really should be there, just searched
a bit through the web before I wrote to you. Start.exe, not
run.exe mutter

I have found it I guess:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q126410

Quote:

You can use the START command to open files if its extension
is a registered file type in Windows. For example, if you type
"start Readme.txt", Notepad is started and the Readme.txt file
is displayed.

Hah, gotta love a memory which still serves well for things
that lie half a decade back and which you used about two times :slight_smile:

Good luck Hal (HTH finally),

-Martin

···

On Sun, Jul 14, 2002 at 04:49:11AM +0900, Hal E. Fulton wrote:

----- Original Message -----
From: “Ariff Abdullah” skywizard@time.net.my
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Saturday, July 13, 2002 1:28 PM
Subject: Re: .rb files in WIndows

On Sunday 14 July 2002 02:00, you wrote:

I think you’re right; I don’t know about XP, though.
See the ‘assoc’ and ‘ftype’ commands; on my Win2k box:

C:>assoc .rb
…rb=rbFile

C:>ftype rbfile
rbfile=“C:\ruby\bin\ruby.exe” “%1” %*

Sure, Xp inherited from NT and ‘NT cmd.exe’ tightly integrated
with native win32 syscall, while win9x DOS ‘command.com’ is
just a plain dos, it know nothing about win32 filetype assoc.

Apparently correct. I can’t do this on Win98 as I
have neither of these executables.