[Tutor] Problem with os.system

Vijay Kumar R vijaya.r at excelindia.com
Fri Mar 1 14:07:29 CET 2013


I was using python for some application which used to create directories and
also to run some exes using the os.system command from a program.py file
which was working fine. For some reasons I got my system formatted and got
the windows 7 installed.

 

Now again I installed python and tried running the same program.py.  The
program executes successfully with no errors but my directory and exes are
not getting invoked.

 

I tried creating the below sample program and executed it

 

#!/usr/bin/env python

import os

global name_wo_ext

name_wo_ext = "d:\\fun"

os.system("mkdir %s" % (name_wo_ext))

 

This gets executed well but there is no directory created L I tried with
another command as below and it works for me 

 

#!/usr/bin/env python

import os

global name_wo_ext

name_wo_ext = "d:\\fun"

if not os.path.exists("%s\\thumbnail\\" % (name_wo_ext)):

                os.makedirs("%s" % (name_wo_ext))

 

 

I am not able to find out why os.system is not executing the commands. 

 

Could somebody please help me out in resolving the problem as I have used
os.system enormously in my program.

 

Thanks and regards,

Vijay R

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130301/dd6cf5ed/attachment.html>


More information about the Tutor mailing list