Windows,从Ruby运行shell脚本?

时间:2012-03-05 01:45:08

标签: ruby bash shell

假设你有一个bash脚本test.sh

#!/bin/sh
echo 'Hello World!'


在Linux中,如果你想在Ruby中运行它,你就可以了

irb(main):001:0> `./test.sh`


在Windows中,您只会收到错误

Errno::ENOEXEC: Exec format error - ./test.sh
        from (irb):2:in ``'
        from (irb):2
        from c:/Ruby193/bin/irb:12:in `<main>'


命令工作正常

irb(main):004:0> `grep`
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.

blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/191120

1 个答案:

答案 0 :(得分:3)

如果您安装了Bash,请尝试:

irb(main):001:0> `bash ./test.sh`