The error you are getting is related to UTF-8 encoding, which is the default encoding in ruby-2.x so I'm assuming you're using 1.8 or 1.9 and you should consider upgrading.
Try adding the following lines to the top of your script:
#!/bin/env ruby
# encoding: utf-8
Let us know if it works and have a look at this thread for more.
EDIT: Now I understood what you want to do. Take a look here for an example file which sits at the bin/
directory. You can put your executable file to another directory like data/
for example, and call through ruby:
#!/usr/bin/env ruby
prog = File.expand_path('../data/myprog', __FILE__)
ARGV.each do|a|
system("#{prog} #{a}") # will return 'true' if run successfully
end
Okay try now. This should work with multiple files also, like
prog file1.doc file2.doc ...