Forum: Ruby Setting Environmental Variables in Ruby script

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B28a3426b4a8ae5ad2302fdf1c6674e8?d=identicon&s=25 Jackster The jackle (jackster)
on 2008-10-15 19:06
I have a scipt that executes a shell command that requires my
environment to be set so the script fails. Is there a way to add my
profile settings into my ruby script?

Thanks

jack
7a561ec0875fcbbe3066ea8fe288ec77?d=identicon&s=25 Sebastian Hungerecker (Guest)
on 2008-10-15 19:15
(Received via mailing list)
jackster the jackle wrote:
> I have a scipt that executes a shell command that requires my
> environment to be set so the script fails. Is there a way to add my
> profile settings into my ruby script?

ENV["varname"] = "value"

HTH,
Sebastian
1bac2e65d64faf472cf2ebc94f0f5ee0?d=identicon&s=25 Ara Howard (ahoward)
on 2008-10-15 19:29
(Received via mailing list)
On Oct 15, 2008, at 11:06 AM, jackster the jackle wrote:

> I have a scipt that executes a shell command that requires my
> environment to be set so the script fails. Is there a way to add my
> profile settings into my ruby script?
>
> Thanks
>
> jack
> --
> Posted via http://www.ruby-forum.com/.
>


cfp:~ > cat this-is-a-bash-question.sh
#! /bin/bash --login

echo $FOO



cfp:~ > ./this-is-a-bash-question.sh

(nothing)



cfp:~ > grep FOO .bash_profile

(nothing)


cfp:~ > echo 'export FOO=42' >> .bash_profile



cfp:~ > ./this-is-a-bash-question.sh
42


a @ http://codeforpeople.com/
B28a3426b4a8ae5ad2302fdf1c6674e8?d=identicon&s=25 Jackster The jackle (jackster)
on 2008-10-15 19:53
Sebastian Hungerecker wrote:
> jackster the jackle wrote:
>> I have a scipt that executes a shell command that requires my
>> environment to be set so the script fails. Is there a way to add my
>> profile settings into my ruby script?
>
> ENV["varname"] = "value"
>
> HTH,
> Sebastian

Thanks Sebastian...my ruby script takes all the variables without error
but my script still fails so I must be missing something in my
environment still. I'll have to do some more checking....thanks again

jack
This topic is locked and can not be replied to.