Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello,

I'm working on porting some code that's been running on mod_perl 1 for a very long time to mod_perl 2. Mostly things have gone smoothly, but I'm having trouble with environment variables. Sometimes my scripts go off and run other scripts, and expect to be able to set things like $ENV{PATH} for the child processes. However, for some reason under mod_perl 2, my environment variables aren't getting passed to child processes! Quite bizarre.

Here's an example:

#!/usr/bin/perl -T use strict; use warnings; print "Content-type: text/plain\n\n"; $ENV{PATH}="/usr/bin"; print "PARENT: PATH is $ENV{PATH}\n"; print " CHILD: PATH is ",`echo \$PATH`,"\n";
The proper output seems pretty obvious, right? And that's what it does when I run it from the command-line. But under mod_perl 2, instead I see:
PARENT: PATH is /usr/bin CHILD: PATH is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbi +n:/bin:/usr/X11R6/bin

I'm using Ubuntu 8.04 and its default Perl (5.8.8), Apache (2.2.8), and mod_perl (2.0.3). My Apache configuration looks roughly like this:

<Location /cgi-perl> Options +ExecCGI PerlSendHeader On SetHandler perl-script PerlHandler ModPerl::Registry PerlOptions +SetupEnv allow from all </Location>
Any suggestions would be appreciated!

In reply to Environment variables under mod_perl 2 by sgifford

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-16 04:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found