What does ruby.exe do?

K

Kaye Ng

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.
 
P

Phillip Gawlowski

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 Gawlowski

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.
 
R

Rajinder Yadav

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.

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 Yadav | 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
 
K

Kaye Ng

Rajinder Yadav wrote in post #958380:
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....
 
L

Luis Lavena

Rajinder Yadav wrote in post #958380:




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 ;-)
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.
 
J

Jeremy Bopp

Rajinder Yadav wrote in post #958380:

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'

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
 
M

Mohit Sindhwani

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 :)

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

Jeremy Bopp

Or you could associate .jeremy with a program that parses the "shebang"
line :)

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. :)

-Jeremy
 
M

Mohit Sindhwani

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. :)

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 :)

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

Mohit Sindhwani

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.

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.
 
R

Rajinder Yadav

Rajinder Yadav wrote in post #958380:

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 Yadav | 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
 

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,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top