Need help dealing with spaces in NT paths.

maytagrepairman at yahoo.com maytagrepairman at yahoo.com
Tue Nov 16 16:42:51 EST 1999


Ok.  This works so far, but to complicate things further I need also to
pass an argument to the command.  Both the command and the argument are
full path names with spaces in them.  If I type something like this at
the DOS prompt:

"my_full_path_cmd_with_spaces" "my_full_path_arg_with_spaces"

it works.

But if I try to do an equivalent such as this in Python

# this next statement is to see what is passed to os.system()
    print ('\"%s\" \"%s\"' % (cmd,arg))

# this next statement is the call to os.system()
    os.system('\"%s\" \"%s\"' % (cmd,arg))

I get

The name specified is not recognized as an
internal or extenal command, operable program or batch file.

Other variations I've tried give the same results.  Any thoughts on
this one?


In article <uogcu93dt.fsf at cs.uu.nl>,
  piet at cs.uu.nl wrote:
> >>>>> wheineman <wheinemanNOwhSPAM at uconect.net.invalid> (W) writes:
>
> W> Put quotes around the complete path. For example:
> W> myExec = "C:\\Program Files\\Trash Can\\compactor.exe"
>
> You probably mean:
> myExec = "\"C:\\Program Files\\Trash Can\\compactor.exe\""
>
> or easier:
> myExec = r'"C:\Program Files\Trash Can\compactor.exe"'
> --
> Piet van Oostrum <piet at cs.uu.nl>
> URL: http://www.cs.uu.nl/~piet [PGP]
> Private email: Piet.van.Oostrum at gironet.nl
>


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list