如何 运行 具有 Ruby 脚本的 .txt 文件,而不在命令行中使用 ruby 命令
How to run a .txt file which has Ruby script, without using the ruby command in the command line
我正在尝试从命令行在 .txt 文件中 运行 一些 ruby 脚本。如果我在 运行 命令之前使用 ruby 命令,则输出是所需的,例如
ruby file_name.txt 10 40
如何在不使用 ruby 命令的情况下执行相同的命令?
如果你在 unix 上,你把 #!/usr/bin/ruby
放在它的顶部,然后 bash
shell 会执行它。
如果你在 Windows,我相信你一定使用了正确的后缀,.rb
或 .rbw
.
我正在尝试从命令行在 .txt 文件中 运行 一些 ruby 脚本。如果我在 运行 命令之前使用 ruby 命令,则输出是所需的,例如
ruby file_name.txt 10 40
如何在不使用 ruby 命令的情况下执行相同的命令?
如果你在 unix 上,你把 #!/usr/bin/ruby
放在它的顶部,然后 bash
shell 会执行它。
如果你在 Windows,我相信你一定使用了正确的后缀,.rb
或 .rbw
.