Hi,
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?
Thanks, -Mike
Hallo, Mike Wozniewski hat gesagt: // Mike Wozniewski 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:
import os
class env(pyext._class):
_inlets = 1
_outlets = 1
def bang_1(self):
for k,v in os.environ.items():
self._outlet(1,(k,v))
def get_1(self, k):
v = os.environ.get(str(k))
if v:
self._outlet(1,(k,v))
else:
print "No such environment var: %s " % k
Try "get PWD" on Unix.
Frank Barknecht _ ______footils.org__
_ __latest track: "scans" _ http://footils.org/cms/show/41
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] else post "No such environment var: %s ", k end end }
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 -'
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?
getenv
t