简体   繁体   中英

Windows, run shell script from Ruby?

Say you have a bash script test.sh

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


In linux if you wanted to run this in Ruby you would just do

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


In Windows you just get an error

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


Commands work fine

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM