Need help dealing with spaces in NT paths.

T. C. Mits 71351.356 at compuserve.com
Wed Nov 17 20:21:18 EST 1999


The commands:
os.system(r'dir "Program Files"')
os.system('dir "Program Files"')

work on win98.   Thanks.

However, certain others do not.  Such as:

>>> os.system('"dir" "Program Files"')
Bad command or file name


Though now that I look at it, it seems trivial, some other newbies may also
get tripped up.
Maybe some experts can add the reasons for these kinds of issues in the
Python FAQs (where ever those are).



<piet at cs.uu.nl> wrote in message news:uzowdfktm.fsf at cs.uu.nl...
> >>>>> "T. C. Mits" <71351.356 at compuserve.com> (TCM) writes:
>
> TCM> A simple example of the difficulty is:
> >>>> os.system(r'"dir Program Files"')
> TCM> Bad command or file name
> TCM> 0
> >>>>
>
>
> TCM> This is run at the root of C: for simplicity.
>
>
> TCM> I also get:
>
> TCM> os.popen(r'"dir Program Files"', "r")
> TCM> Bad command or file name
> TCM> <open file '"dir program files"', mode 'r'  at 795930>
>
> TCM> What does that mean?
>
> It means there is no program with the name: dir program files
> You should use:
>
> os.system(r'dir "Program Files"')
> os.popen(r'dir "Program Files"', "r")
> --
> Piet van Oostrum <piet at cs.uu.nl>
> URL: http://www.cs.uu.nl/~piet [PGP]
> Private email: Piet.van.Oostrum at gironet.nl






More information about the Python-list mailing list