Yeah, it's pretty cool.
If you're on posix , fire up a terminal and type 'set' 'env' (thank you fullermd!), this shows you the system environment variables. All of these are accessible in your perl script as : $ENV{VARNAME}.
This is nifty, like with $ENV{HOME}- of what user your script is running as.
The catch is .. the environment variables available to your script running called from apache will access different environment variables as called from the command line,
So that..
#!/usr/bin/perl use CGI ':all'; print header; print "<pre>\n"; map { print "$_ $ENV{$_}\n" } sort keys %ENV; print "</pre>\n";
Gives you different results if called via cli or via apache (or other httpd).
For example, cgi side, you will see 'DOCUMENT_ROOT', which is not present under the cli side. Inversely, HOME is set on cli side, but not on cgi side. Likely for security reasons.
Different http servers will have different variables set. This depends on the configuration of the specific box in question.
In reply to Re: how to access apache environment variables
by leocharre
in thread how to access apache environment variables
by patpark
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |