FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 12-10-2010, 06:20 PM
"James B. Byrne"
 
Default /bin/env

Please forgive my ignorance but I need a explanation of how to
accomplish the following since I cannot figure it out from the
documents.

I have a Ruby script with a shebang line that looks like this:

#!/usr/bin/env ruby

On one particular host I have two Ruby interpreters installed; one
the CentOS base version 1.8.6 in /usr/bin/ruby the other version
1.8.7 in /usr/local/bin/ruby. In my shell the which command finds
/usr/local/bin/ruby. In a cron job the /usr/bin/ruby is used by the
/bin/env invocation.

My question is: How does one configure /bin/env to return the
/usr/local/bin/ruby version? or does that question even make sense?

I have looked at the alternatives command but that seems just a tad
involved. And since this is a production server I am not quite
ready to trust to RVM either.

In the short term I have simply removed the CentOS version which has
resolved the immediate issue. However, I would like to know how to
handle this a little more elegantly in future.




--
*** E-Mail is NOT a SECURE channel ***
James B. Byrne mailto:ByrneJB@Harte-Lyne.ca
Harte & Lyne Limited http://www.harte-lyne.ca
9 Brockley Drive vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada L8E 3C3

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-10-2010, 06:27 PM
Bill Campbell
 
Default /bin/env

On Fri, Dec 10, 2010, James B. Byrne wrote:
>Please forgive my ignorance but I need a explanation of how to
>accomplish the following since I cannot figure it out from the
>documents.
>
>I have a Ruby script with a shebang line that looks like this:
>
>#!/usr/bin/env ruby
>
>On one particular host I have two Ruby interpreters installed; one
>the CentOS base version 1.8.6 in /usr/bin/ruby the other version
>1.8.7 in /usr/local/bin/ruby. In my shell the which command finds
>/usr/local/bin/ruby. In a cron job the /usr/bin/ruby is used by the
>/bin/env invocation.
>
>My question is: How does one configure /bin/env to return the
>/usr/local/bin/ruby version? or does that question even make sense?

The /bin/env command uses the $PATH environment variable to find
the argument. If you want to invoke a specific version of ruby,
change the PATH variable or replace this with:

#!/usr/local/bin/ruby

Bill
--
INTERNET: bill@celestial.com Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
Voice: (206) 236-1676 Mercer Island, WA 98040-0820
Fax: (206) 232-9186 Skype: jwccsllc (206) 855-5792

A paranoid is a man who knows a little of what's going on.
-- William S. Burroughs
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-10-2010, 06:28 PM
Benjamin Franz
 
Default /bin/env

On 12/10/2010 11:20 AM, James B. Byrne wrote:
> Please forgive my ignorance but I need a explanation of how to
> accomplish the following since I cannot figure it out from the
> documents.
>
> I have a Ruby script with a shebang line that looks like this:
>
> #!/usr/bin/env ruby
>
> On one particular host I have two Ruby interpreters installed; one
> the CentOS base version 1.8.6 in /usr/bin/ruby the other version
> 1.8.7 in /usr/local/bin/ruby. In my shell the which command finds
> /usr/local/bin/ruby. In a cron job the /usr/bin/ruby is used by the
> /bin/env invocation.
>
> My question is: How does one configure /bin/env to return the
> /usr/local/bin/ruby version? or does that question even make sense?
>

Why not just change the shebang line to use

#!/usr/local/bin/ruby

?

--
Benjamin Franz

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-10-2010, 06:32 PM
Robert Heller
 
Default /bin/env

At Fri, 10 Dec 2010 14:20:12 -0500 (EST) CentOS mailing list <centos@centos.org> wrote:

>
> Please forgive my ignorance but I need a explanation of how to
> accomplish the following since I cannot figure it out from the
> documents.
>
> I have a Ruby script with a shebang line that looks like this:
>
> #!/usr/bin/env ruby
>
> On one particular host I have two Ruby interpreters installed; one
> the CentOS base version 1.8.6 in /usr/bin/ruby the other version
> 1.8.7 in /usr/local/bin/ruby. In my shell the which command finds
> /usr/local/bin/ruby. In a cron job the /usr/bin/ruby is used by the
> /bin/env invocation.
>
> My question is: How does one configure /bin/env to return the
> /usr/local/bin/ruby version? or does that question even make sense?

PATH=/usr/local/bin:$PATH

Compare the value of PATH in your shell vs. the cronjob.

>
> I have looked at the alternatives command but that seems just a tad
> involved. And since this is a production server I am not quite
> ready to trust to RVM either.
>
> In the short term I have simply removed the CentOS version which has
> resolved the immediate issue. However, I would like to know how to
> handle this a little more elegantly in future.
>
>
>
>

--
Robert Heller -- 978-544-6933 / heller@deepsoft.com
Deepwoods Software -- http://www.deepsoft.com/
() ascii ribbon campaign -- against html e-mail
/ www.asciiribbon.org -- against proprietary attachments



_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-12-2010, 04:50 AM
Brian Mathis
 
Default /bin/env

On Fri, Dec 10, 2010 at 2:20 PM, James B. Byrne <byrnejb@harte-lyne.ca> wrote:
> Please forgive my ignorance but I need a explanation of how to
> accomplish the following since I cannot figure it out from the
> documents.
>
> I have a Ruby script with a shebang line that looks like this:
>
> #!/usr/bin/env ruby
>
> On one particular host I have two Ruby interpreters installed; one
> the CentOS base version 1.8.6 in /usr/bin/ruby the other version
> 1.8.7 in /usr/local/bin/ruby. *In my shell the which command finds
> /usr/local/bin/ruby. *In a cron job the /usr/bin/ruby is used by the
> /bin/env invocation.
>
> My question is: How does one configure /bin/env to return the
> /usr/local/bin/ruby version? *or does that question even make sense?
>
> I have looked at the alternatives command but that seems just a tad
> involved. *And since this is a production server I am not quite
> ready to trust to RVM either.
>
> In the short term I have simply removed the CentOS version which has
> resolved the immediate issue. *However, I would like to know how to
> handle this a little more elegantly in future.


I'm not sure who came up with the "/usr/bin/env" thing (though I
understand what they were trying to do), but it's exceedingly stupid.
Even the smallest bit of testing would have easily revealed these
kinds of problems with it. The solution is to simply not use it and
directly invoke the interpreter.
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-12-2010, 11:24 AM
David Sommerseth
 
Default /bin/env

On 12/12/10 06:50, Brian Mathis wrote:
> On Fri, Dec 10, 2010 at 2:20 PM, James B. Byrne<byrnejb@harte-lyne.ca> wrote:
>> Please forgive my ignorance but I need a explanation of how to
>> accomplish the following since I cannot figure it out from the
>> documents.
>>
>> I have a Ruby script with a shebang line that looks like this:
>>
>> #!/usr/bin/env ruby
>>
>> On one particular host I have two Ruby interpreters installed; one
>> the CentOS base version 1.8.6 in /usr/bin/ruby the other version
>> 1.8.7 in /usr/local/bin/ruby. In my shell the which command finds
>> /usr/local/bin/ruby. In a cron job the /usr/bin/ruby is used by the
>> /bin/env invocation.
>>
>> My question is: How does one configure /bin/env to return the
>> /usr/local/bin/ruby version? or does that question even make sense?
>>
>> I have looked at the alternatives command but that seems just a tad
>> involved. And since this is a production server I am not quite
>> ready to trust to RVM either.
>>
>> In the short term I have simply removed the CentOS version which has
>> resolved the immediate issue. However, I would like to know how to
>> handle this a little more elegantly in future.
>
>
> I'm not sure who came up with the "/usr/bin/env" thing (though I
> understand what they were trying to do), but it's exceedingly stupid.
> Even the smallest bit of testing would have easily revealed these
> kinds of problems with it. The solution is to simply not use it and
> directly invoke the interpreter.

I probably disagrees with you here. The /usr/bin/env thing solves issues with
script interpreters being installed in a different location than usually, like
/opt/my-own-tweaks/bin.

You may disagree that this is not appropriate, but in some settings this is
highly needed if you think about cross-platform support. F.ex. a program
using scripts which really only works with bash and on some Unix boxes that is
unstalled under, say /usr/gnu/bin.

So by putting /usr/gnu/bin in an appropriate position in the global PATH
variable and using /usr/bin/env ... that script will also work without any
tweaks on a multitude of platforms without needing to be modified. And of
course you have similar issues when running a script via cron.

I would rather try to figure out why /usr/bin/env doesn't report
/usr/local/bin early in the path for cron jobs to start with. That's the core
issue in this context. So as was suggested earlier, compare the PATH variable
from a shell and via a cron job and try to figure out why it is different.


kind regards,

David Sommerseth



_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 07:41 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org