How to execute a Ruby script in Terminal?

前端 未结 9 1617
南笙
南笙 2020-12-04 06:15

I\'ve set everything up that I need on my Mac (Ruby, Rails, Homebrew, Git, etc), and I\'ve even written a small program. Now, how do I execute it in Terminal? I wrote the pr

9条回答
  •  借酒劲吻你
    2020-12-04 07:13

    To call ruby file use : ruby your_program.rb

    To execute your ruby file as script:

    1. start your program with #!/usr/bin/env ruby

    2. run that script using ./your_program.rb param

    3. If you are not able to execute this script check permissions for file.

提交回复
热议问题