When I try to open A ruby file in the same directory something weird happens,
like so :
C:\RubyFiles>file = File.open("Lottery.rb", "r")
'file' is not recognized as an internal or external command, operable program or batch file.
now I know this has nothing to do with the opening of the file itself, but I wanted to have an example ;)
(This has been resolved^) :D
But now I would like to know how to run the file itself? Can anyone help? Thanks in advance!
After opening irb, you can execute a ruby file using Kernel#load
load 'Lottery.rb'
If this file just includes module/class definitions, you probably only want to load it once. This is what Kernel#require ensures:
require 'Lottery.rb'
Related
I have a ruby script that I run from the terminal, however I want to be able to double-click an icon like I would an application and run the script. I've looked at ruby-packer, but it isn't working for me.
What is the best option to accomplish this?
Im on a mac.
In terminal, I'm not at the directory of the .rb file because when I try to run ./rubyc from the directory containing the .rb file, I get the error command not recognized
When I run ./rubyc /RubyProjects/signOff.rb /signOff.out I'm able to get it to run, but the outfile file is called rubyc that just re-runs the same code when I double-click it. I'm at a loss for how to get it to work properly.
`
The -o parameter defines the output filename:
rubyc -o signOff signOff.rb
I'm a very beginner in this kind of stuff so I suppose the solution for this problem may not be so difficult.
I'm trying to open the GUI file of MEKA (an extension to weka) and it's manual tells me to execute a file called: run.sh.
I go to the console and type 'my file's location'/run.sh and what happens is I get the message: "The main class could not be located and loaded", or something like that.
This is the content of the run.shfile:
#!/bin/bash
MEMORY=512m
MAIN=meka.gui.explorer.Explorer
java -Xmx$MEMORY -cp "./lib/*" $MAIN $1
So any tips?
Thank you.
The script depends on it being run from the folder it resides in. Try:
cd fileLocation
./run.sh
"dex2jar classes.dex" is not recognized as an internal or external command, operable program or batch file.
i got this problem when im trying to generate a classes.dex.jar
i think my environment variables have the problem but i cant figure it out..,
HELP ME OUT!!
THANKS IN ADVANCE
provide a snippet of your code (to make answering your question easier). 2. you could try using the start command like this:
start your-programs-divided by "|" or "&" then "the path of the file here" (in quotes)
another quick note you may need to have it open a java in order to run the .JAR file.
I have been running my Ruby program using the Git Bash console for a while now.
Lately, when I wanted to run a simple ruby program, i go the following on the console:
c:\Ruby187\bin\ruby.exe: No such file or directory
Why is that? And, how can I solve this issue?
Thanks.
Check the PATH environment variable under both User and System.
Looks like it sees where it should be. Potentially a permissions issue? Can you run with a regular command prompt? Start->run, cmd.exe, ruby -v?
It seems that I had to explicitly save my ruby program with the extension .rb added at the end of the file name for this problem to disappear.
Thanks.
Scenario :
I mapped a network drive on a Win XP machine and I double click a .bat file to execute this Ruby script. The .rb and .bat file reside on this networked drive.
The batch file is as follows :
Z:
cd Z:\ABC\StatusCheck\
"C:\Program Files\Ruby\Bin\ruby.exe" Z:\ABC\StatusCheck\rubyScript.rb 6
The Ruby file is as follows :
require 'watir'
rec = File.open("list.txt", "r")
ie = Watir::IE.start()
***Other processing here***
My Question : How do I instantiate this batch file using Linux (when I am at home cos I cannot remote into to this machine. I want to run the .rb file from the terminal)?
Hope I made sense. I really appreciate your time guys! Thank you!
You don't need any batch file to run this on linux. All you need to do is run the script directly with
ruby rubyScript.rb
or add
#!/usr/bin/env ruby
to the top of rubyScript.rb and make it executable, then you can run directly.
However, your bigger problem is that you are using watir to automate IE, which obviously won't work on Linux, so you'll need to change it to use another browser.