我试图使用Ruby一些图像执行以下bash命令:为什么从Ruby中调用Bash命令会引发错误?
class Pingcrush
def initialize
Dir.foreach('drawable') do |item|
next if item == '.' or item == '..'
# do work on real items
if item.end_with?(".png") then
%x["wine pngcrush.exe -brute drawable/#{item} new/#{item}"]
end
end
end
end
Pingcrush.new
我在该目录的父既drawable
和new
,但是,当我试图运行该脚本我总是得到相同的错误:
sh: wine pngcrush.exe -brute drawable/feed_cl.png new/feed_cl.png: not found
为什么会发生这种情况?我尝试转换我在Ruby中调用的路径,似乎无法完成此工作。
我试过这个。似乎没有修复它。同样的错误。 – Aidanc 2011-06-02 14:38:59
@Aidanc,你应该给葡萄酒和你的exe文件(pngcrush.exe)的完整路径。 – 2011-06-03 02:57:30