Reputation: 2805
I am not at all proficient in unix or perl or cgi or apache but have been assigned to find a way to set an environment variable on unix from a cgi web page.
I can successfully set the Environment variable
$ENV{PROGPATH}=$Data{PROGPATH};
But when a 4ge program is launched and then itself launches another program, this variable seems to 'go away'. I think I need to run the command
export PROGPATH;
To make it 'stick' for the second program.
I can't seem to find a way to do this successfully from the cgi page that launches the first program.
Upvotes: 0
Views: 79
Reputation: 1927
In Perl, the system
command executes any given command intended for the command line. Here, it is necessary to export $PROGPATH
and so the full command would be
system("export $PROGPATH");
Note that this might leave your system vulnerable to various attacks, so you may want to ensure that $PROGPATH
gets sanity checked prior to this call.
Upvotes: 1
Reputation: 791
Simple to do:
$ENV{FOO}=1;
system('echo FOO=$FOO');
When Perl runs system, it exports the variables to the forked process.
Upvotes: 1