[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: wrapper script issue



On Fri, Feb 08, 2008 at 02:02:30PM -0700, ChadDavis wrote:
> First of all, I have wrapped my ruby binary in wrapper script as just indicated. 
> the wrapper script is called "ruby1.8" and here's the contents:
> 
> #!/bin/sh
> export RUBYOPT=rubygems
> exec /etc/alternatives/ruby1.8 "$@"

Do you really want to quote the argument list?

> I'm trying to execute the following ruby script, matz.rb
> 
> #!/usr/bin/ruby1.8
> puts "Hello, Matz!"

Not likely the problem, but I'd suggest putting your wrapper into
/usr/local/bin/, or somewhere other than /usr/bin/, so that it doesn't
risk colliding with packaged software.  I have a /usr/bin/ruby1.8
on my system, and it's clearly not your wrapper.  Or maybe I'm just
misunderstanding something...

> If I execute this script with explicit command line use of the ruby wrapper
> script, such as:
> 
> me@myhost:~/temp/rubyTest$ ruby1.8 matz.rb
> 
> everything works fine!

My guess is that it would not work if matz.rb was given an argument, since
it would then look like 

    me@myhost:~/temp/rubyTest$ ruby1.8 "matz.rb arg".

> The problem arises when I try to take advantage of the shebang notation to invoke
> the ruby script with out explicit command line invocation of the ruby binary,
> ala:
> 
> me@myhost:~/temp/rubyTest$ matz.rb
> 
> results in:
> 
> ./matz.rb: line 2: puts: command not found
> 
> What am I missing here?

I don't know, but would suggest adding some simple debug statements
to your wrapper and other scripts to check and make sure you're doing
what you think you're doing.

-- 
Ken Irving, fnkci+debianuser@uaf.edu


Reply to: