python call external program (WHAT THE?!)
Ben Thomas
bthomas at trey-industries.com
Tue Sep 14 11:31:04 EDT 1999
I just tried but putting the batch file in three places on a drive. The I tried
them all.
system('d:\mybat.bat') = ok
system('d:\data\mybat.bat') = ok
system('d:\data\vacman\mybat.bat') = fails, it works fine from DOS prompt!
what gives?
Ben
Andreas Cardeneo wrote:
> 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