Zombo
Zombo

Reputation: 1

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

Upvotes: 1

Views: 1280

Answers (1)

ruakh
ruakh

Reputation: 183201

If you have Bash installed, try:

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

Upvotes: 3

Related Questions