[Tutor] Executing a command from a specific directory

Alan Gauld alan.gauld at btinternet.com
Wed Sep 16 09:54:26 CEST 2009


"Ansuman Dash" <ansuman.dash at gmail.com> wrote

> In Python scripting, how can I execute a command (which can be run from
> spcific directory) and then retrieve the result (after executing the 
> command
> it give the command is executed successfull or not), so that I can 
> validate
> it.

There are sweveral ways to do this but the preferred route is using the
subprocess module.

You can see examples of several of the options in the Using the OS
topic in my tutorial, under the heading "Manipulating Processes".

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 




More information about the Tutor mailing list