Reputation: 31
any way to create an 'executable' file in ruby so you can run file.rb with ./file
I know you can just run ruby files ruby filename.rb
I also want to be able to send arguments so ./file argument_1 argument_2
Upvotes: 0
Views: 450
Reputation: 21569
#! /usr/bin/env ruby
to your first line of file.rb
file.$ chmod +x file.rb
$ ./file.rb
use ARGV
.
#! /usr/bin/env ruby
puts " parameter0 is: #{ARGV[0]}"
puts " parameter1 is: #{ARGV[1]}"
output:
$ ./test.rb a b
parameter0 is: a
parameter1 is: b
.rb
filefor more details, refer to: https://techforluddites.com/windows-10-change-the-default-programs-for-opening-files/
Upvotes: 1