Command shell access within Python

Pierre Rouleau pieroul at attglobal.net
Sun Nov 4 20:10:26 EST 2001


> But as noted in this thread,
> popen also starts a shell for each command, so it doesn't really solve
> your problem, if this is actually a problem :-).

It's not that it is a problem.  But I was trying to create an Python
object that I would be able to use where I would change directories,
change environment variables values (or add/delete environment variables).

Using os.system(), os.popenXX() and the like the environment of these
sub-processes are lost after every invocation.
I guess my other bet would be to re-direct stdin/stdout/stderr to a shell
process, but then I would not have access to the returned shelled program
value.

When i first tried os.system() i tried it within the IDLE system in NT.
Under IDLE in NT, every time your call os.system(), a shell window pops up
briefly while the command runs.  I was trying to avoid that.  Later, i
noticed that if i run python from a shell directly, os.system() does not
behave like that (no other window pops up).


Thanks for the help!

Pierre




More information about the Python-list mailing list