Ruby调用Bash命令时错误频发,原因究竟何在?

更新于
2026-10-09 22:35:50
1阅读来源:SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计178个文字,预计阅读时间需要1分钟。

Ruby调用Bash命令时错误频发,原因究竟何在?

我正在尝试使用Ruby在某些图像上执行以下bash命令:

rubyclass Pingcrush def initialize Dir.foreach('drawable') do |item| next if item=='.' or item=='..' end endend

我正在尝试使用 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中调用的路径,似乎无法使其工作.

它执行你的shell但找不到酒.尝试设置安装wine的完整路径.

Ruby调用Bash命令时错误频发,原因究竟何在?

which wine

本文共计178个文字,预计阅读时间需要1分钟。

Ruby调用Bash命令时错误频发,原因究竟何在?

我正在尝试使用Ruby在某些图像上执行以下bash命令:

rubyclass Pingcrush def initialize Dir.foreach('drawable') do |item| next if item=='.' or item=='..' end endend

我正在尝试使用 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中调用的路径,似乎无法使其工作.

它执行你的shell但找不到酒.尝试设置安装wine的完整路径.

Ruby调用Bash命令时错误频发,原因究竟何在?

which wine