[Tutor] Commandline and backslash problem

Remco Gerlich scarblac@pino.selwerd.nl
Sun, 28 Oct 2001 22:18:31 +0100

On  0, nhytro-python@web.de wrote:

> Quite right Roeland! I noticed this also 30mins ago, my application works
> "halfway" now. The wierdest, saddest thing is that switches donīt work with
> os.system():
> ### example
> def howzat():
> ....prog = "C:\\blah.exe"
> ....switch = "-q"
> ....file = "aha.txt"
> os.system("%s %s %s" %(prog, switch, file))
> #### end example
> the commandline application mentions "error, file not found-> -q" ,
> apparently it thinks that the switch is a file, this is then skipped and it
> executes but without the switch.

This is in fact proof that os.system() gave the switch to the command
blah.exe; that blah.exe doesn't know that it is a switch, well that's not
something os.system can do anything about...

> Are switches built this way passed separately to the commandline? I took a
> look at execl and spawnv, they didīnt work in my function, they just did not
> execute the commandline application :-(

No, it's just one command line. blah.exe doesn't have a switch '-q'.

Remco Gerlich