help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] How to access environment variables ?


From: Stephen
Subject: Re: [Help-smalltalk] How to access environment variables ?
Date: Wed, 11 Feb 2009 00:55:16 +1300
User-agent: Thunderbird 2.0.0.19 (Macintosh/20081209)



I am trying to use it in a CGI script and get the entire CGI environment. The above works, but it gives me the shell environment variables. Two different things.

My understanding is that with CGI all the parameters are only available to the process as environment variables. I googled a BASH script and a Perl script, and then compared with the simple GST script below. When run on Linux I can extract the same information with all three scripts. Are you getting different results on your platform?

--------------------------
PERL demo CGI script
#!/usr/bin/perl
##
##  printenv -- demo CGI program which just prints its environment
##

print "Content-type: text/plain\n\n";
foreach $var (sort(keys(%ENV))) {
   $val = $ENV{$var};
   $val =~ s|\n|\\n|g;
   $val =~ s|"|\\"|g;
   print "${var}=\"${val}\"\n";
}

--------------------
GST demo CGI script

#!/usr/local/bin/gst -f

Transcript showCr: 'Content-type: text/plain'; nl.

cgivars := {'SERVER_SOFTWARE'. 'HTTP_ACCEPT'. 'HTTP_HOST'. 'REQUEST_URI' }.
cgivars do: [ :env |
   Transcript showCr: env,':',(Smalltalk getenv: env)].

Transcript nl; showCr: '==== All Env Vars below ==============';nl.
pipe := FileStream popen: ('set',logFile) dir: FileStream read.
Transcript showCr: pipe contents.
! !

Regards
Stephen






reply via email to

[Prev in Thread] Current Thread [Next in Thread]