Avoiding shell metacharacters in os.popen
nick at craig-wood.com
Thu Sep 30 13:30:14 CEST 2004
Donn Cave <donn at u.washington.edu> wrote:
> 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,
No me neither!
> I'm just taking it from you that os.popen2 doesn't support a list
> of parameters  on Microsoft Windows platforms,
Well it didn't work when I tried it.
> 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
It could always do " ".join(cmd) which would leave windows users
exactly where they are at the moment.
I'll probably end up writing a little wrapper to popen2 which does
something like that, possibly with a bit better quoting for windows.
> 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.
Good point. I'll have a think about it (and a look at the Windows
source of popen2!)
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list