2012-03-05 113 views
0

假設你有一個bash腳本test.shWindows,從Ruby運行shell腳本?

#!/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

回答

3

如果您已經安裝了bash,試試:

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