python call external program
Andreas Cardeneo
Andreas.Cardeneo at mach.uni-karlsruhe.de
Tue Sep 14 11:24:39 EDT 1999
Ben Thomas wrote:
>
> very simple question:
>
> What would I do to have Python execute something from the DOS command
> line. I am very new to python but I bet it is in a moudule but don't
> know the command or the modules to look in. I want to
>
> dir >%myvar.txt
>
> #this code would run dir from the command line and pass the var "myvar"
> , dir would dump a listing of the files into a text file called xxxx.txt
>
> pointers?
>
> Ben
Hi Ben,
you should use the system() function from the "os" module.
os.system("dir *.txt") shows all files in the current directory matchin
*.txt.
The function returns the exit code.
Bye,
Andreas
--
Andreas Cardeneo Universität Karlsruhe (TH)
Tel: +49 721 608-4576 Institut für Fördertechnik und Logistiksysteme
Fax: +49 721 75 83 78 Hertzstraße 16 - 76187 Karlsruhe
eMail: Andreas.Cardeneo at mach.uni-karlsruhe.de
More information about the Python-list
mailing list