I want my Ruby Script File to run as executable from any directory of Windows XP. I have created a test.rb (Ruby Script file) and want to run it from any directory of my Windows as "test" for example, "C:\test" or "C:\Directory\test" runs my file test.rb.
#!/usr/bin/envy ruby
p "Hi this is my test file"
I have added the shebang code in my ruby file but when I have to run the Ruby Script, I have to locate my Script file and run it expicitly as "ruby test.rb".
I have also made the file executable by executing the command:$ chmod +x hello-world.rb
, but it still does not work.
Thanks in advance.
I assume you're using Linux or OS X and creating the file on a disk accessible from Windows? Windows does not use shebangs, and it does not use Unix file modes. You will need to associate files with the .rb
extension to the Ruby executable; details for that operation can be found at this Stack Overflow question; once you have done this, you can run C:\whatever\test.rb
or C:\whatever\test
to execute the script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With