[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] How to access environment variables ?
From: |
Mehul Sanghvi |
Subject: |
Re: [Help-smalltalk] How to access environment variables ? |
Date: |
Mon, 28 Mar 2011 12:32:43 -0400 |
On Mon, Mar 28, 2011 at 09:57, Mehul Sanghvi <address@hidden> wrote:
> On Mon, Mar 28, 2011 at 09:52, Paolo Bonzini <address@hidden> wrote:
>> On 03/28/2011 03:42 PM, Mehul Sanghvi wrote:
>>>
>>> gst> Smalltalk getenv: 'SHELL'
>>> '/bin/bash'
>>> gst>
>>>
>>> I didn't think I needed it when I was doing the environ statement.
>>
>> You didn't need it for "Smalltalk environ" indeed. But here,
>>
>>> which is different from
>>>
>>> gst> Smalltalk environ:
>>>
>>> the last one needing a '.' to make it a complete statement or an object.
>>
>> adding a "." would only make a syntax error, because you need an argument
>> after "environ:", just like you had one above "getenv:".
>>
>> Tip: if you think it's complicated, you aren't understanding it. :)
>>
>> Paolo
>>
>
> More like not paying attention to it. :)
>
>
> --
> Mehul N. Sanghvi
> email: address@hidden
>
I've attached a patch so that environ can be supported from GST.
And this is what my final test-cgi.st script looks like :)
Just ignore the fact that I use GNU style for naming my variables
rather then the CamelCase style that is the convention in Smalltalk.
------ BEGIN CODE ----------
#!/usr/local/bin/gst -f
Transcript showCr: 'Content-type: text/html'; nl .
'' displayNl .
'<HTML>' displayNl .
'<HEAD><TITLE>Testing CGI/Smalltalk</TITLE></HEAD>' displayNl .
'<BODY>' displayNl .
'<H2>Yo! Smalltalk, Whats up ? </H2>' displayNl .
env := Smalltalk environ .
env_dict := Dictionary new.
[ (env_string := env value) isNil ] whileFalse: [
match := env_string =~ '(.*?)=(.*)'.
env_dict at: (match at: 1) put: (match at: 2).
env incr ].
env_sorted := env_dict keys asSortedCollection.
Transcript nl ; showCr: '==== All Env Vars below ====== <br>'; nl.
env_sorted do: [ :a_key |
Transcript show: a_key .
ans := env_dict at: a_key.
Transcript show: ' = '; show: ans; cr.
].
'</BODY>' displayNl .
'</HTML>' displayNl .
-------------- END CODE ------
Thanks for the help Paolo and the patience. Hopefully the patch makes it in.
cheers,
mehul
--
Mehul N. Sanghvi
email: address@hidden
environ-patch.diff
Description: Text Data
- Re: [Help-smalltalk] How to access environment variables ?, (continued)
- Re: [Help-smalltalk] How to access environment variables ?, Paolo Bonzini, 2011/03/27
- Re: [Help-smalltalk] How to access environment variables ?, Mehul Sanghvi, 2011/03/27
- Re: [Help-smalltalk] How to access environment variables ?, Paolo Bonzini, 2011/03/28
- Re: [Help-smalltalk] How to access environment variables ?, Mehul Sanghvi, 2011/03/28
- Re: [Help-smalltalk] How to access environment variables ?, Paolo Bonzini, 2011/03/28
- Re: [Help-smalltalk] How to access environment variables ?, Mehul Sanghvi, 2011/03/28
- Re: [Help-smalltalk] How to access environment variables ?,
Mehul Sanghvi <=
- Re: [Help-smalltalk] How to access environment variables ?, Paolo Bonzini, 2011/03/28