Welcome to WebmasterWorld Guest from 107.20.28.48

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Passing Environment Variables to Command Line Call

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

Administrator from US 

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

joined:Sept 21, 1999
posts:38057
votes: 12


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)
7:32 pm on May 29, 2012 (gmt 0)

Senior Member

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

joined:Nov 12, 2005
posts:5966
votes: 0


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...]
4:25 pm on May 30, 2012 (gmt 0)

Senior Member

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

joined:Nov 28, 2004
posts:7999
votes: 0


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 . . .
2:51 pm on May 31, 2012 (gmt 0)

Full Member

5+ Year Member

joined:Mar 22, 2011
posts:339
votes: 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
7:39 pm on June 1, 2012 (gmt 0)

Administrator from US 

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

joined:Sept 21, 1999
posts:38057
votes: 12


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.
11:48 pm on June 1, 2012 (gmt 0)

Administrator

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

joined:July 31, 2003
posts:12537
votes: 0


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...]
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members