Embedding UNIX Commands

Erno Kuusela erno-news at erno.iki.fi
Mon Feb 12 19:33:45 EST 2001


In article <mailman.982008497.29571.python-list at python.org>, D-Man
<dsh8290 at rit.edu> writes:

| I don't think you can use setenv -- that is a csh thing, and system()
| won't even start up a shell (AFAIK).  Even if it did, it wouldn't do
| you any good since that shell would terminate and its environment
| would be meaningless.  (Also, on Linux systems bash is the default
| shell)

actually, system() (and popen()) pass the command line to /bin/sh
under unix.

| It would probably be better if you described what you want to
| accomplish with these commands and then people can come up with a
| different way that wouldn't rely on the underlying system (and PATH).

| If you simply want to change the environment of your python process
| you can :

| import sys
| sys.env[ "VAR" ] = "value"


| (also possibly the sys.setenv() function, try  dir( sys ) , and  print
| sys.setenv.__doc__ )

those should be os.environ and os.putenv instead of sys.env and sys.setenv.

  -- erno



More information about the Python-list mailing list