Avoiding shell metacharacters in os.popen

Donn Cave donn at u.washington.edu
Thu Sep 30 00:22:35 CEST 2004


In article <slrnclm1vh.oif.nick at irishsea.home.craig-wood.com>,
 Nick Craig-Wood <nick at craig-wood.com> wrote:
...
> What my post was about was avoiding the shell completely.  If you use
> os.system(string) then you go via the shell.  However if you use
> os.spawnl(mode, file, *args) then it doesn't go anywhere near the
> shell.  As I pointed out in my post there isn't an equivalent for
> os.popen* which doesn't go via the shell (except for undocumented
> os.popen2).

Well, it sounded to me like the real problem is that Microsoft
Windows doesn't support any functional equivalent to spawnv
for pipes.  I don't know if that's true or not, I'm just
taking it from you that os.popen2 doesn't support a list of
parameters [1] on Microsoft Windows platforms, and inferring
that it doesn't because it can't - there isn't any specific
function that does it, and you can't just roll your own out
of pipe/fork/execve like you can on UNIX, as in fact popen2 does.

If that's really a question and not a well known fact, you
might pose it again  with a subject line that would attract
more attention from Microsoft Windows developers, since
only they would know.  The attempt to cast it as a general
Python problem could be counterproductive, if it means the
people who read about this problem tend to be those who
don't really suffer from it.

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list