gpt4 book ai didi

ruby - 为什么从 Ruby 调用 Bash 命令会抛出错误?

转载 作者:数据小太阳 更新时间:2023-10-29 07:48:50 24 4
gpt4 key购买 nike

我正在尝试使用 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

我所在的目录是 drawablenew 的父目录,但是,当我尝试运行脚本时,我总是遇到相同的错误:

sh: wine pngcrush.exe -brute drawable/feed_cl.png new/feed_cl.png: not found

为什么会这样?我尝试切换我在 Ruby 中调用的路径,但似乎无法完成这项工作。

最佳答案

它正在执行您的 shell 但找不到 wine。尝试设置安装 wine 的完整路径。

which wine

关于ruby - 为什么从 Ruby 调用 Bash 命令会抛出错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6215901/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com