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: Mehul N. Sanghvi
Subject: Re: [Help-smalltalk] How to access environment variables ?
Date: Mon, 09 Feb 2009 00:40:04 -0500
User-agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)

Stephen said the following on 01/14/2009 10:15 PM:
Mehul N. Sanghvi wrote:

I would like to be able to get at all of the environment variables (whether it is the shell environment variables or the CGI environment variables or something else). What object/class would I use for that ?


There is a way of getting it with an OS call...

$ gst
GNU Smalltalk ready

st> | pipe |
st> pipe := FileStream popen: 'set'  dir: FileStream read
<Pipe on set>
st> pipe contents
'AUTO_SYMLINK=no
BASH=/bin/sh
BASH_ARGC=()
BASH_ARGV=()
BASH_EXECUTION_STRING=set
BASH_LINENO=()
BASH_SOURCE=()
....




In code, something like:
    osCall: cmd [
        | pipe |
        pipe := FileStream popen: cmd dir: FileStream read.
        ^pipe contents.
    ]


Then call it like:-

Transcript show: (osCall: 'set').
or
Transcript show: (osCall: 'ls -l').



Stephen



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.


cheers,

    mehul





reply via email to

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