[Tutor] commandline, os.system, backslash revisted

nhytro-python@web.de nhytro-python@web.de
Sun, 28 Oct 2001 22:44:53 +0100


Seems like I spoke to soon.

I tried out several things and noticed that this worked:

#### code snippet

def go_app():
........textfile = inputfile.get() # inputfile is a tkintet entry widget
........textfile = string.replace(textfile, '/', '\\')
........editor = editorpath.get()# editorpath is a tkinter entry widget
........editor = string.replace(editor, '/', '\\')
........editor = editor + " -test" # switch test
........os.system(r"%s %s" % (editor, textfile))
........
############## end code 

I tried out a file that had "dangerous" characters:
c:\the\boy.txt

the commandline application was correctly called but the file above caused a "file not found" error. I did a print to screen and saw that the path was trashed: " theoy.txt "

Is there no sure way to run commandline executables with switches with os.sytem? also switches built into a command (example "c:\foo.exe -test") always fail, with a file not found error.

This is very saddening, any clues? help?


Thanks in advance


Sharriff 


________________________________________________________________
Lotto online tippen! Egal zu welcher Zeit, egal von welchem Ort.
Mit dem WEB.DE Lottoservice. http://tippen2.web.de/?x=13