From: Jayson Williams Date: 2008-11-26T01:55:26+09:00 Subject: Re: Can you run a command line script with arguments, without typing 'ruby' first? Mohit, I thought this would work also, but for some reason it is not. I currently can run any ruby script from anywhere. The only issue I have is when its a script run from the command line that needs args. The script still runs, but I can tell that the args are not being read. If I run the same script with ruby, it works fine. The only things I can think of that might be causing this are: 1) ruby may think that the arguments are meant for the interpreter instead of my script. So they are being consumed by the interpreter and my script never sees them. Is there a way to tell ruby the the args are not for the interpreter? 2) I am using the global array ARGV[x] to read in command line arguments. Is there a better method. The rubyscript2exe method is working, but is a bit cumbersome when I have to make small changes. Being able to run the script with args directly would be best for me. Thanks Mohit! On Tue, Nov 25, 2008 at 12:14 AM, Mohit Sindhwani wrote: > Pit Capitain wrote: >> >> 2008/11/24 Kyle Schmitt : >> >>> >>> Jayson, hum. I guess that makes sense. Now that I'm thinking back I >>> never used command line options on my windows-ruby stuff, (...) >>> >> >> FWIW, I never had problems calling Ruby scripts with command line >> args, and I just enter the script name without "ruby". Currently I'm >> using the OCI on Windows 2000... >> > > I think the steps should be something like: > 1. Add Ruby Interpreter path to your path to make sure that you can run Ruby > from anywhere > 2. In Explorer, go to a folder that has a Ruby script ending with an > extension of .rb > 3. Press shift and right click on the .rb file there > 4. In the context menu, it should give an option called 'Open with' - if > that has the Ruby interpreter in it, click on it. If that works, great! > 5. Alternatively, click on 'Choose Program' - navigate to your ruby install > and select ruby.exe > 6. Click on 'Always use the selected program' - say OK, etc. > 7. Go to a command prompt and try to run your ruby script without ruby in > the name and with the parameters > command>myscript.rb param1 > It should work. > > Note that the associations need to be set up in the GUI and the script must > be run from the command line with the parameters. It has worked like that > for me for months. Do post if there's a problem. > > I think using Rubyscript2exe for this is a bit of a troublesome way - since > you may want to change your script, etc. and having to repackage it all the > time just to try something simple is a pain! > > Cheers, > Mohit. > 11/25/2008 | 1:18 PM. > > > > >