I'm a bit confused as to your scenario. I think you have something like the following:
You are trying to run example.exe from a perl script that you wrote. Unfortunately, example.exe requires that the MYVAR environment variable be set. To do this, you could do something like this in your perl script:
$ENV{MYVAR} = "MYVAR value";
To elaborate, web servers (or at least Apache; I have little experience with others) tend to trim their environment so as to limit the amount of damage a black hat could wreak on a server where the environment was left in tact, so to speak. So, if you need a special environment variable set for something to run, you should set it explicitly as I demonstrated above.
thor
Feel the white light, the light within
Be your own disciple, fan the sparks of will
With all of us waiting, your kingdom will come
| [reply] [d/l] |
Hi,
I'm not sure I understand your question here, but I'll try to answer anyway.
To call environment variables from CGI.pm you use the %ENV hash.
So try using $ENV{'MYVAR'} to get your information.
A good writeup of this can be found at
CGI
PM CGI tutorials
Neil | [reply] |
I bet the env var is probably only defined for your user and needs to be defined for all users, or at least for the user as which the web server runs. Try to right-click on My Computer, select 'Advanced', select 'Environment Variables' and enter MYVAR with the appropriate value in the System Variables area. If that doesn't work, check if you can create env vars from within your web server's configuration tool.
| [reply] |
Huzzah!! Virtual Guinness for all
Yep, setting up the environment variable with $ENV sorted out the problem nicely. Didn't know that apache messed around with enivonment stuff.
Thanks all :-)
| [reply] |
Yup. Here's a small CGI script that I wrote - nothing special - to print out the cgi environment on Windoze XP:
#!C:\Perl\bin
use strict;
######## Start the HTML ########
print <<END_HTML;
<html>
<head>
<title>Perl CGI Environment Variables</title>
<STYLE type="text/css">
<!--
H1.page_title {text-align: center; color: blue}
-->
</STYLE>
</head>
<body>
<h1 class="page_title">Perl CGI Environment Variables</h1>
<table border="1">
<tr>
<th bgcolor="#99ccff">\@INC Paths</th>
</tr>
END_HTML
### 1st print out the @INC array ###
my $ct = 0;
foreach my $dir (@INC) {
print <<END_HTML;
<tr>
<td><b>$dir</b></td>
</tr>
END_HTML
$ct++;
}
######## Finish the @INC HTML #########
print <<END_HTML;
</table>
<br>
<br>
<table border="1">
<tr>
<th bgcolor="#99ccff">Env Variable Name</th>
<th bgcolor="#99ccff">Value</th>
</tr>
END_HTML
### Next print out all the environment variables ###
foreach my $name (sort keys %ENV) {
print <<END_HTML;
<tr>
<td><b>$name</b></td>
<td>$ENV{$name}</td>
</tr>
END_HTML
}
######## Finish the HTML #########
print <<END_HTML;
</table>
</body>
</html>
END_HTML
Put this in your webserver's document root. I called it "env.pl", so access it by:
http://your.server.com/env.pl
and see what environment variables it displays.
HTH. | [reply] [d/l] [select] |