os.system prob

Donn Cave donn at u.washington.edu
Mon Aug 9 23:00:50 CEST 2004


In article <mailman.1412.1092079959.5135.python-list at python.org>,
 Aaron Barclay <aaronb at jhcs.co.uk> wrote:

> I am trying to send some commands via os.system but am getting tripped 
> up by it stripping out the quote marks. I have:

Quoting can be tricky, when you have multiple layers of
interpretation - python, shell, etc.  You can probably
figure it out with some experimentation, but if possible
it's better to avoid the problem.  Use os.spawnv - like,

  os.spawnv(os.P_WAIT, '/usr/local/bin/whatever',
           ['whatever', 'parameter one'])

This invokes the command directly, so there's no shell
command line parsing.

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list