[英]Windows, run shell script from Ruby?
假設你有一個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.
如果您安裝了Bash,請嘗試:
irb(main):001:0> `bash ./test.sh`
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.