[Baypiggies] translating shell environment variables

Shiqi Yang sherman.yang at gmail.com
Wed Aug 27 21:10:07 CEST 2008

Hi, My python code is reading some xml files that have several shell
style environment variables like "$_" or "$$".
for example:
<var name='tmp_log_file'>/tmp/$$.log</var>
I need to extract them and translate them into real value when I read the file.

Now I can only think of two ways of doing this,
1 is to have a big dictionary in my python code which have all the
mappings from shell to python os module(or others as well)
another way is to get shell involved and have it pre-process the file,
but I'm afraid that way some of the values may not be well translated
since the context switch (like the pids, etc).

Are there any python module that could help this kind of task?
or anyone has done similar work can share your experience?

Any help will be highly appreciated.


Sherman Yang

More information about the Baypiggies mailing list