Welcome to WebmasterWorld Guest from 50.19.135.67

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Passing Environment Variables to Command Line Call

     

Brett_Tabke

2:54 pm on May 29, 2012 (gmt 0)

WebmasterWorld Administrator brett_tabke is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Calling a perl script via back ticks out of php.

On server A the entire set of environment variables is available.

On server B, they are not.

Both are running Cpanel.

Both are running same set of scripts on each server.

Apache http env variables is what I am after in the perl program.

This issue ring a bell with anyone? (it is almost deja vu with me. seems I've run into this before)

eelixduppy

7:32 pm on May 29, 2012 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



The Apache environment variables are set by Apache itself. I do not think this is a PHP configuration issue, but I may be wrong.

How are you fetching the values -- $_SERVER[], getenv(), or apache_getenv()?


Also: [httpd.apache.org...]

rocknbil

4:25 pm on May 30, 2012 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Apache http env variables is what I am after in the perl program.


And in perl of course you already know PHP's $_SERVER = Perl's %ENV . . . However . . . since it's the PHP script that's being requested, $_SERVER['REQUEST_URI'] (and referrer, etc.) will be available to the PHP script, but $ENV{'REQUEST_URI'} is not likely to be available to the Perl script because it's not being requested by a client, it's being "requested" by the PHP script. Is that what you mean? You'd pass the value as an argument vector in that case . . .

rlange

2:51 pm on May 31, 2012 (gmt 0)



If you're only missing the Apache environment variables, the only thing I can think of is that PHP on Server A is running as an Apache module, while on Server B it's running as CGI.

I believe PHP running as CGI doesn't have access to Apache's environment variables, because the process isn't actually part of the Apache environment. (Edit: I'm sort of doubting this now. I can't find any confirmation. Bleh. )

--
Ryan

Brett_Tabke

7:39 pm on Jun 1, 2012 (gmt 0)

WebmasterWorld Administrator brett_tabke is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



in middle of php (a wordpress post with exec php mod on)


<?php
$output = `perl /public_html/webmasterworld/testfun.cgi`;
echo "$output";
?>

That runs fine on this server. The perl script has the entire environment there for it. I use that to death over on the pubcon site here because most of the substructure is still perl.

On another server, same script, same wordpress db - I get nothing for variables. I stumped. Something is running to block them.

coopster

11:48 pm on Jun 1, 2012 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Things I would check first ... PHP ini setting for environment variables. Run a simple script to see if $_SERVER and/or $_ENV are getting populated:


<pre>
<?php
print_r($_SERVER);
print_r($_ENV);
?>
</pre>


If not, check variables_order:
[php.net...]
and track_vars too.

If it's not those PHP configuration directives than it may be security-related:
[php.net...]

And safe_mode and openbase_dir are the first that always come to mind ...
[php.net...]
 

Featured Threads

Hot Threads This Week

Hot Threads This Month