Batch commands on Windows
jcarlson at nospam.uci.edu
Sat Jan 24 06:31:15 CET 2004
> It is a small subset, but an important subset. Shell scripting started
> probably when people got sick of typing the same commands into the prompt.
> For a language to really support shell scripting, it should provide a way of
> automating the process of typing in the commands. As in, there should be no
> difference whether you're actually typing, or you're running the script.
Python is not a shell, nor scripting language. It does contain an
interactive interpreter for executing Python code, and it does have
support for executing programs through calling a shell, but that does
not necessitate (or warrant) it having every feature for shell scripting
that everyone wants.
JanC makes a great point about the fact that commands are run in a
subshell, and any environment changes are lost when the subshell
terminates. I believe this is by design.
Perhaps you should look into os.popen2 and friends. You can execute a
command shell (cmd.exe or command.com), send it commands, and read its
output. On Windows it is a little awkward right now, but os.popen5 is
supposed to make it easy to deal with such things. Hopefully it will
make it into Python 2.4.
More information about the Python-list