What does ruby.exe do?

In my folder C:\Ruby192\bin , there is ruby.exe

What is it and what does it do?

The book I’m reading gives an option of running Ruby
this way:
create a shortcut to the Ruby executable file (ruby.exe)
and drop your source code file(s) onto it.

If i have saved a file named example1.rb, how do I ‘drop’
it onto ruby.exe ?

Thanks geniuses.

On Sat, Oct 30, 2010 at 11:34 AM, Kaye Ng [email protected] wrote:

In my folder C:\Ruby192\bin , there is ruby.exe

What is it and what does it do?

In light of what you wrote below: Take a guess…

The book I’m reading gives an option of running Ruby
this way:
create a shortcut to the Ruby executable file (ruby.exe)
and drop your source code file(s) onto it.

If i have saved a file named example1.rb, how do I ‘drop’
it onto ruby.exe ?

The way you drag and drop files when copying them, except you release
the mouse button on your ruby.exe (icon or actual program). Note,
though, that unless you source code calls for input or pauses
execution, you’ll only see the DOS prompt flashing on your screen
(unless your source code takes a while to complete, anyway).


Phillip G.

Though the folk I have met,
(Ah, how soon!) they forget
When I’ve moved on to some other place,
There may be one or two,
When I’ve played and passed through,
Who’ll remember my song or my face.

On 10-10-30 05:34 AM, Kaye Ng wrote:

it onto ruby.exe ?

Thanks geniuses.

just put “C:\Ruby192\bin” at the end of your path environment, open up
cmd.exe in the folder where the example lives, and then type

‘ruby.exe example1.rb’

get use to typing in the command line and rebuke the ms gui ide drag &
drop mentality, you will be better off in the the long run


Kind Regards,
Rajinder Y. | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-22-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.1

On Oct 31, 11:51pm, Kaye Ng [email protected] wrote:

‘ruby.exe example1.rb’

May I ask why ‘ruby.exe example1.rb’ when ‘example1.rb’ alone is
sufficient?
beginner here =) no knowledge whatsoever.

That only works if during installation of Ruby you check the box to
associate .rb and .rbw files with the interpreter.

You can also type ‘ruby ex’ and hit tab to get the filename
autocompleted :wink:

but I was just wondering why you suggested that. is it a conventional
way or something? I’m still not sure why ruby.exe exists in the bin
folder, I find testing programs in command prompt a lot easier…and i
don’t feel like using SciTE.exe (text editor) either…

Normally speaking is good to invoke scripts with “ruby” before since
it works across platforms.

Some scripts for certain projects will not have .rb extension and the
system will not be able to determine what to do with them.

ruby.exe exist because it is the Ruby interpreter. If you remove it
your way of invoking the script (example1.rb) will not work.

On 10/31/2010 08:51 PM, Kaye Ng wrote:

‘ruby.exe example1.rb’
and it works exactly like the ‘ruby.exe example1.rb’
It works because there must be a file association for files with the .rb
extension to be run by ruby.exe. Windows is a bit special in this
regard. Unix systems handle associating scripts with programs in a
different way that is not supported under Windows. Too bad too, because
the Unix way is much more flexible.

For instance, I can name a file myscript.jeremy and configure it so that
it will be run with Ruby, Python, Perl, or some other interpreter of my
choosing. I could then create another file named myotherscript.jeremy
and set it up to run using a completely different interpreter.

This is not possible under Windows. The .jeremy extension can only be
associated with a single program, so one of those files would have to be
run by manually calling the correct program with the file as an
argument.

but I was just wondering why you suggested that. is it a conventional
way or something? I’m still not sure why ruby.exe exists in the bin
folder, I find testing programs in command prompt a lot easier…and i
don’t feel like using SciTE.exe (text editor) either…

The ruby.exe file is the program that runs, or interprets, Ruby scripts
on your system. Without ruby.exe, your scripts cannot run. As a quick
experiment, rename ruby.exe to ruby.exe.bak and then try running your
script. Unless you have a different ruby.exe than the one you renamed
configured to run your scripts, you should get a nice error.

Keep in mind that none of this is unique to Ruby. If you install Python
or Perl, you’ll find they have python.exe and perl.exe files in their
respective bin directories as well.

-Jeremy

Rajinder Y. wrote in post #958380:

On 10-10-30 05:34 AM, Kaye Ng wrote:

it onto ruby.exe ?

Thanks geniuses.

just put “C:\Ruby192\bin” at the end of your path environment, open up
cmd.exe in the folder where the example lives, and then type

‘ruby.exe example1.rb’

May I ask why ‘ruby.exe example1.rb’ when ‘example1.rb’ alone is
sufficient?
beginner here =) no knowledge whatsoever.

i’m using windows xp, what i do is:
c:
c:\Ruby192\Practice (that’s where i keep my sample program)
then type example1.rb
and it works exactly like the ‘ruby.exe example1.rb’

but I was just wondering why you suggested that. is it a conventional
way or something? I’m still not sure why ruby.exe exists in the bin
folder, I find testing programs in command prompt a lot easier…and i
don’t feel like using SciTE.exe (text editor) either…

On 1/11/2010 12:34 PM, Jeremy B. wrote:

For instance, I can name a file myscript.jeremy and configure it so that
it will be run with Ruby, Python, Perl, or some other interpreter of my
choosing. I could then create another file named myotherscript.jeremy
and set it up to run using a completely different interpreter.

This is not possible under Windows. The .jeremy extension can only be
associated with a single program, so one of those files would have to be
run by manually calling the correct program with the file as an argument.

Or you could associate .jeremy with a program that parses the “shebang”
line :slight_smile:

Cheers,
Mohit.
2/11/2010 | 12:13 AM.

On 11/1/2010 11:13 AM, Mohit S. wrote:

Or you could associate .jeremy with a program that parses the “shebang”
line :slight_smile:

That’s actually a great idea. Can you recommend such a program? It
should be fairly easy to write one, but no sense reinventing the wheel.
:slight_smile:

-Jeremy

On 30/10/2010 5:34 PM, Kaye Ng wrote:

it onto ruby.exe ?

Thanks geniuses.

Just since no one else has actually answered this last bit, you could
make a shortcut to the Ruby interpreter (ruby.exe) at a place of your
choosing (e.g. the Desktop) while the main executable stays in the
c:\ruby192\bin directory. Then, you can drag any ruby program and drop
it onto that short cut. This will invoke the interpreter with your
program as the program to run. You’ll soon get bored of this method
since it’s not very flexible and doesn’t allow you to pass arguments to
your script, etc.

One more note - I do get the feeling that the book you’re reading is for
Ruby before Ruby 1.9. Be aware that a few things have changed and you
may see some inconsistencies between what the book says and what your
programming shows since you’re using Ruby 1.9.

Best Regards,
Mohit.
2/11/2010 | 12:50 AM.

On Sun, Oct 31, 2010 at 9:51 PM, Kaye Ng [email protected] wrote:

‘ruby.exe example1.rb’

May I ask why ‘ruby.exe example1.rb’ when ‘example1.rb’ alone is
sufficient?

because someone here posted once that .rb extension failed to get
registered in windows during install, i was too lazy to go into
details then =P

the way you’re doing it is fine, my was a more fool proof method if
typing example.rb failed to work


Kind Regards,
Rajinder Y. | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-22-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.1

On 2/11/2010 12:16 AM, Jeremy B. wrote:

Or you could associate .jeremy with a program that parses the “shebang”
line :slight_smile:
That’s actually a great idea. Can you recommend such a program? It
should be fairly easy to write one, but no sense reinventing the wheel. :slight_smile:

I’ve never used one for it, but I was just a bit offended by the “This
is not possible under Windows.” line… so, I suggested the first
thing that came to mind. But, if you do write one, I’d love to have a
copy :slight_smile:

Cheers,
Mohit.
2/11/2010 | 12:48 AM.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs