Can you run a command line script with arguments, without typing 'ruby' first?

Daniel Schömer wrote:

restricted to 9 arguments).

Daniel

OK! I have it here… I just checked through the Windows XP stuff on my
PC…
I think this is what you need to do.

  1. Open a folder.
  2. Select Tools > Folder Options
  3. Tab: File Types
  4. Scroll down till you find RB in the list
  5. In the box that says ‘Details for …’ click on [Advanced]
  6. There is a box called ‘Actions’
  7. Select the open action - create a new one called open if it isn’t
    there
  8. In the pop-up window, these are my settings:
    Action: open
    Application used to perform this action: “c:\ruby\bin\ruby.exe” “%1”
    %*
    [x] use DDE
    Application: ruby
    Topic: System
    (other fields blank)
    [OK]

Try?

Cheers,
Mohit.
11/26/2008 | 1:50 AM.

WoooHooooo!!! That did it. The arguments were there except the last
%* was in quotes. Took the quotes off and presto. I can now do

my_script args

and get the correct output.

Thanks everyone!

Jayson

Kyle S. wrote:

Jayson, if your not on a real OS, you need to associate the extension
.rb with the interpreter. It’s been a little while since I’ve done
this in windows, but it’s actually pretty straightforward. You may
have to google for how to associate the script with the interpreter
though, as I don’t recall the exact steps.

That used to happen when installing the 1-click[sic] version.

(It’s in the PATHEXT system environment variable. I think there has to
be something n the registry as well, but you could get that by
right-clicking a .rb file and selecting the app to always open files of
that type.)

Anyways, on my Vista box, it all works fine. I type the name of a
script, no file extension, passing args, and all is super cool awesome.

I’ve never had to explicitly invoke ruby, even on XP. It’s one case
where Windows did the right thing reliably. :slight_smile:


James B.

www.happycamperstudios.com - Wicked Cool Coding
www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff

Jayson W. wrote:

WoooHooooo!!! That did it. The arguments were there except the last
%* was in quotes. Took the quotes off and presto. I can now do

You’re most welcome :slight_smile:

Jayson W. wrote:

I don’t believe these arguments are included in the association. I am
not sure how to add them.

I don’t remember the exact menu/option names, but this should be
the way to check:

  • Windows Explorer, Menu ‘Extras’, ‘Folder Options’. Or Control
    Panel, ‘Folder Options’
  • Tab ‘Filetypes’
  • Scroll to ‘.rb’ and select
  • Button ‘Advanced’ or ‘Extended’ on the bottom right
  • Now there should be a textfield containing ‘…\ruby.exe’. Try
    to add “%*” or “%1” “%2” … (try with and without quotes)
    after ruby.exe

(%1 gets replaced by the first argument, %2 by the second,
limited to 9 arguments. %* should be replaced by all arguments)

Daniel

Frustratingly, I got this working fine at work. I can type
my_script args
and I get the proper results. Now my propblem is my home pc. I have
tried all the fixes above, but I still have to type

my_script.rb args
unless I inclued the .rb extension, the script will not run.

Jayson W. wrote:

Frustratingly, I got this working fine at work. I can type
my_script args
and I get the proper results. Now my propblem is my home pc. I have
tried all the fixes above, but I still have to type

my_script.rb args
unless I inclued the .rb extension, the script will not run.

In general, you should need to type in the extension as part of the
program name cos the extension is what tells Windows what to do with
it. The exception is a list of extensions that Windows treats as
executables. These are usually .exe, .com, . bat, .cmd etc - in these
cases, typing the extension is optional.

This is controlled in a variable called PATHEXT in the environment. In
a command window, I did:
command>set

This gives me a list of extensions that are already there:
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.RB;.RBW

(note .rb and .rbw at the end)

Add that to your PATHEXT and try?

Cheers,
Mohit.
11/29/2008 | 4:13 PM.

Mohit,

YOU ROCK !
I am embarrassed to have been goofing with computers for so many years
without knowing these basics. Anyway everything is working the way I
want, and I have learned some very useful basics.
Thanks!

Jayson

Jayson W. wrote:

Mohit,

YOU ROCK !
I am embarrassed to have been goofing with computers for so many years
without knowing these basics. Anyway everything is working the way I
want, and I have learned some very useful basics.
Thanks!

me too :slight_smile:
I had these items in peripheral vision, but your queries made me chase
them down :stuck_out_tongue:

Cheers,
Mohit.
11/30/2008 | 1:42 PM.