[PD] access environment variables from Pd?

Mathieu Bouchard matju at artengine.ca
Thu Jun 23 00:28:27 CEST 2005

On Wed, 22 Jun 2005, Frank Barknecht wrote:
>> Does anyone know if it's possible to access Linux environment variables
>> from within Pd?  ie, in a message object?  ...or would I have to write
>> an external for this?
> You could do it with pyext:

you can also do it in Ruby:

GridFlow::FObject.subclass("env",1,1) {
   def _0_bang; ENV.each {|k,v| send_out 0, [k,v.intern] } end
   def _0_get k
     v = ENV[k.to_s]
     if v then
       send_out 0, [k,v.intern]
       post "No such environment var: %s ", k

> Try "get PWD" on Unix.

Or for that special purpose, one can also use this external instead 
(which just needs a bang):

GridFlow::FObject.subclass("pwd",1,1) {def _0_bang; send_out 0,Dir.pwd.intern; end}

note that the latter uses a systemcall whereas the former uses the 
environment-variables. cross fingers that both are synched. ;-)

,-o--------o--------o--------o-. ,---. irc.freenode.net #dataflow |
| The Diagram is the Program tm| | ,-o-------------o--------------o-.
`-o------------o-------------o-' | | Mathieu Bouchard (Montréal QC) |
   | téléphone:+1.514.383.3801`---' `-o-- http://artengine.ca/matju -'

More information about the Pd-list mailing list