os.system(cmd) isn't working

F. Petitjean littlejohn.75 at news.free.fr
Thu Jun 23 04:44:18 EDT 2005


Le Thu, 23 Jun 2005 01:19:11 -0500, Paul Watson a écrit :
> "Gregory Piñero" <gregpinero at gmail.com> wrote in message 
> news:mailman.787.1119499378.10512.python-list at python.org...
> Hi guys,
>
> I'm trying to run this statement:
>
> os.system(r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + '
> "www.blendedtechnologies.com"')
>
> The goal is to have firefox open to that website.

I suggest to use the subprocess module. You don't have insert " around a
path with embedded spaces and you can give the exact executable
pathname, set the directory for the child process, etc

import os
import os.path
import subprocess
path_exe = r'C:\Program Files\Mozilla Firefox\firefox.exe'
assert os.path.exists(path_exe)
url = "http://www.blendedtechnologies.com"
child = subprocess.Popen( (path_exe, url), executable = path_exe)
rc = child.wait()

> I'm using Python 2.3 on Windows XP pro service pack 2.

I think that subprocess is a new Python2.4 module, but you should be
able to find a 2.3 version (perhaps effbot.org)
>
> I'd greatly appriciate any help.



More information about the Python-list mailing list