Loading ...
Sorry, an error occurred while loading the content.
 

Re: setting environment variables

Expand Messages
  • Stas Bekman
    ... That s probably due to the differences of how perl and Apache interpret environ on win32. mod_perl really calls perl s funcs to get the env. I m sure if
    Message 1 of 11 , Feb 1, 2005
      colin_e wrote:
      > Geoff,
      > I ran into some weirdness in this area (on a Win XP machine running
      > Apache 2.0.52)
      > that seemed to be related to using lowercase environment variable names.
      > It looked as if
      > PerlSetEnv uppercased the variable names, whereas SetEnv just ignored
      > vars with lower
      > case names.
      >
      > Sounds weird I know, and I didn't pin it down exactly, but try uppercase
      > variables and
      > see if this works for you.

      That's probably due to the differences of how perl and Apache interpret
      environ on win32. mod_perl really calls perl's funcs to get the env. I'm
      sure if you try that on the command line (plain perl) you will see the
      same behavior. something like:

      setenv foo bar (whatever it is on win32)
      perl -le 'print $ENV{FOO}'

      on unix that won't work, but on win32 it should print 'bar'.

      I believe Randy has mentioned this before.

      How does mp1 deals with that?

      Randy?


      --
      __________________________________________________________________
      Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
      http://stason.org/ mod_perl Guide ---> http://perl.apache.org
      mailto:stas@... http://use.perl.org http://apacheweek.com
      http://modperlbook.org http://apache.org http://ticketmaster.com
    • Randy Kobes
      ... That s right, Stas - on Win32, C: set foo=bar C: perl -le print $ENV{FOO} prints bar . ... There is a difference in this respect between mp1 and
      Message 2 of 11 , Feb 1, 2005
        On Tue, 1 Feb 2005, Stas Bekman wrote:

        > colin_e wrote:
        > > Geoff,
        > > I ran into some weirdness in this area (on a Win XP
        > > machine running Apache 2.0.52) that seemed to be related
        > > to using lowercase environment variable names. It
        > > looked as if PerlSetEnv uppercased the variable names,
        > > whereas SetEnv just ignored vars with lower case names.
        > >
        > > Sounds weird I know, and I didn't pin it down exactly,
        > > but try uppercase variables and see if this works for
        > > you.
        >
        > That's probably due to the differences of how perl and
        > Apache interpret environ on win32. mod_perl really calls
        > perl's funcs to get the env. I'm sure if you try that on
        > the command line (plain perl) you will see the same
        > behavior. something like:
        >
        > setenv foo bar (whatever it is on win32)
        > perl -le 'print $ENV{FOO}'
        >
        > on unix that won't work, but on win32 it should print 'bar'.

        That's right, Stas - on Win32,
        C:\> set foo=bar
        C:\> perl -le "print $ENV{FOO}"
        prints "bar".

        > I believe Randy has mentioned this before.
        >
        > How does mp1 deals with that?
        >
        > Randy?

        There is a difference in this respect between mp1 and mp2.
        For example, with a registry script that has
        print "Foo = $ENV{Foo}<BR />";
        print "FOO = $ENV{FOO}<BR />";
        print "foo = $ENV{foo}<BR />";
        one obtains:

        - under Apache1/mp1,
        SetEnv Foo Bar
        SetEnv FOO BAR
        yields
        Foo = BAR
        FOO = BAR
        foo = BAR
        whereas
        PerlSetEnv Foo Bar
        PerlSetEnv FOO BAR
        yields
        Foo = BAR
        FOO = BAR
        foo = BAR
        So under mp1, SetEnv and PerlSetEnv behave the same,
        as far as case goes.

        - under Apache2/mp2,
        SetEnv Foo Bar
        SetEnv FOO BAR
        yields
        Foo = bar
        FOO = bar
        foo = bar
        whereas
        PerlSetEnv Foo Bar
        PerlSetEnv FOO BAR
        yields
        Foo = BAR
        FOO = BAR
        foo = BAR

        So the behaviour of SetEnv changed from Apache-1 to
        Apache-2, as far as Win32 case goes, while PerlSetEnv
        maintained the same behaviour from mp1 to mp2.

        I suppose one could argue that we should change
        PerlSetEnv under mp2 to lower-case things, so as
        to be consistent with SetEnv?

        --
        best regards,
        randy
      • Stas Bekman
        Randy Kobes wrote: [...] ... I think yes. I m sure you have a patch already :) -- __________________________________________________________________ Stas
        Message 3 of 11 , Feb 2, 2005
          Randy Kobes wrote:
          [...]
          > So the behaviour of SetEnv changed from Apache-1 to
          > Apache-2, as far as Win32 case goes, while PerlSetEnv
          > maintained the same behaviour from mp1 to mp2.
          >
          > I suppose one could argue that we should change
          > PerlSetEnv under mp2 to lower-case things, so as
          > to be consistent with SetEnv?

          I think yes. I'm sure you have a patch already :)



          --
          __________________________________________________________________
          Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
          http://stason.org/ mod_perl Guide ---> http://perl.apache.org
          mailto:stas@... http://use.perl.org http://apacheweek.com
          http://modperlbook.org http://apache.org http://ticketmaster.com
        • Randy Kobes
          ... Actually, things are a bit more complicated on mp2 than I thought ... The example I gave earlier had 2 SetEnv/PerlSetEnv directives, differing in case,
          Message 4 of 11 , Feb 2, 2005
            On Wed, 2 Feb 2005, Stas Bekman wrote:

            > Randy Kobes wrote:
            > [...]
            > > So the behaviour of SetEnv changed from Apache-1 to
            > > Apache-2, as far as Win32 case goes, while PerlSetEnv
            > > maintained the same behaviour from mp1 to mp2.
            > >
            > > I suppose one could argue that we should change
            > > PerlSetEnv under mp2 to lower-case things, so as
            > > to be consistent with SetEnv?
            >
            > I think yes. I'm sure you have a patch already :)

            Actually, things are a bit more complicated on mp2 than I
            thought ... The example I gave earlier had 2
            SetEnv/PerlSetEnv directives, differing in case, which is a
            bit artificial. If there's just one such directive, then
            both SetEnv/PerlSetEnv seem to behave normally (taking into
            account that, on Windows, $ENV{FOO} and $ENV{foo} are the
            same). However, there does seen to be a problem (with
            SetEnv) when it's all lower-case
            SetEnv foo bar
            in that $ENV{foo} doesn't seem to get set (irrespective of
            the case of "foo". There's still a difference between
            PerlSetEnv and SetEnv, but I don't see the pattern yet;
            I'll keep looking.

            --
            best regards,
            randy
          • colin_e
            Yes I think it s more complicated. I don t have the original setup that caused my problem, but i m pretty sure I found that if I set a mixed-case env var (say
            Message 5 of 11 , Feb 4, 2005
              Yes I think it's more complicated.

              I don't have the original setup that caused my problem, but i'm pretty
              sure I found
              that if I set a mixed-case env var (say 'MyEnv_Var') with SetEnv, in my
              mod_perl
              app I got the variable set (exists == true) but with no value, whereas
              using PerlSetEnv
              with the same variable name, I got the value in %ENV but the var name
              was uppercased.

              At the moment i have just worked around the problem by using SetEnv but
              with an
              all uppercase varaible name.

              Regards; Colin
              Randy Kobes wrote:

              >On Wed, 2 Feb 2005, Stas Bekman wrote:
              >
              >
              >
              >>Randy Kobes wrote:
              >>[...]
              >>
              >>
              >>>So the behaviour of SetEnv changed from Apache-1 to
              >>>Apache-2, as far as Win32 case goes, while PerlSetEnv
              >>>maintained the same behaviour from mp1 to mp2.
              >>>
              >>>I suppose one could argue that we should change
              >>>PerlSetEnv under mp2 to lower-case things, so as
              >>>to be consistent with SetEnv?
              >>>
              >>>
              >>I think yes. I'm sure you have a patch already :)
              >>
              >>
              >
              >Actually, things are a bit more complicated on mp2 than I
              >thought ... The example I gave earlier had 2
              >SetEnv/PerlSetEnv directives, differing in case, which is a
              >bit artificial. If there's just one such directive, then
              >both SetEnv/PerlSetEnv seem to behave normally (taking into
              >account that, on Windows, $ENV{FOO} and $ENV{foo} are the
              >same). However, there does seen to be a problem (with
              >SetEnv) when it's all lower-case
              > SetEnv foo bar
              >in that $ENV{foo} doesn't seem to get set (irrespective of
              >the case of "foo". There's still a difference between
              >PerlSetEnv and SetEnv, but I don't see the pattern yet;
              >I'll keep looking.
              >
              >
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.