problem with os.system calls under win32
gresham at mediavisual.com
Fri Apr 14 14:30:32 EDT 2000
Actually I was trying a similar thing, and decided to be smart and use
but this is what happened:
>>> import os
>>> os.system(os.path.join("D:","My Documents","test.bat"))
'D:\My' is not recognized as an internal or external command,
operable program or batch file.
>>> os.path.exists(os.path.join("D:","My Documents","test.bat"))
That's a bit confusing !
Of course from Gordon's example:
>>> os.system('"%s"' % (os.path.join("D:","My Documents","test.bat")))
"Gordon McMillan" <gmcm at hypernet.com> wrote in message
news:1256392132-57146878 at hypernet.com...
> william_93402 at my-deja.com wrote:
> > I am attempting to do a system call in a directory with spaces in the
> > name. For example:
> > >>>import os
> > >>>os.system('c:\\f o o\\bar.exe')
> > 1
> > when I place the executable in a dir such as c:\\foo I can successfully
> > execute the system call. Is there something special I have to do when
> > directory names contain spaces? Just for notes I am running by example
> > in build 125 of pythonwin.
> Follow MS's rules:
> os.system('"c:\\f o o\\bar.exe"')
> (must be double-quotes).
> - Gordon
More information about the Python-list