Problem with Dos command by python script

Chris Rebert chris at rebertia.com
Thu Sep 15 03:57:54 CEST 2011


On Wed, Sep 14, 2011 at 1:13 PM, Jonatas Emidio <jonatasemidio at gmail.com> wrote:
> Here i come!!
>
> I have the following problem...
> I need run by python script a string with some "DOS commands - Windows
> prompt"!!
> For exemple:
> print 'cd temp'
> print 'mkdir temp_app'
>
> How can i run this string in the python, but as a DOS interpreter?

Use the `subprocess` module, and pass shell=True.
http://docs.python.org/library/subprocess.html

Cheers,
Chris



More information about the Python-list mailing list