Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Environment variable set in Apache not recognized by tcl script

Status
Not open for further replies.

sara2005

Programmer
Nov 6, 2012
2
0
0
US
I am having trouble setting a new environment variable in Apache and later reading it from a Tcl script.

Here is what I have done:
1) Set new environment variable in Apache start script (apachectl) in the /path/to/apache/bin folder
export STAGING="staging"

2) Start Apache server

3) Read all environment variables and print to screen using a Tcl script:
Code:
#!/path/to/tclsh
#
set host $env(SERVER_NAME) <-------- this works
set webstg $env(STAGING)   <-------- this doesn't!!!

puts "Content-Type:   text/html\n\n"
puts "Hello world!!!<br \>"

puts "host is $host <br \>"
puts "region is $webstg <br \>"

I am not able to figure out why the new environment variable I introduced in Apache settings is not picked-up by Tcl script. Greatly appreciate any help to resolve this. Please note that the same approach works in PHP scripting.

Thanks,
Saravan
 
Hi

Not all environment craps are passed to CGI script. That could be a security issue.

Use the [tt]PassEnv[/tt] directive to explicitly allow passing your environment forward :
Code:
PassEnv STAGING


Feherke.
[link feherke.github.com/][/url]
 
Feherke, Thanks a lot. I have it working now.

regards,
Saravan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top