Why does invoking a Bash command from Ruby throw an error?

I am trying to execute the following bash command on some images using Ruby:

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

The directory I'm in is the parent of both drawable, and new, however, when I try to run the script, I always get the same error:

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

Why is this happening? I tried switching to the path that I am calling in Ruby and cannot do this work.

+3
source share
3 answers

Performs its shell, but cannot find wine. Try to establish the full path to the installation location of the wine.

which wine
+5
source

Do not put quotation marks around your team.

+1
source

You noted that it wine pngcrush.exe -brute drawable/feed_cl.png new/feed_cl.pngworks when you type it from the command line, right?

+1
source

All Articles