[Tutor] File access by os.system

lohith madireddy lohithreddym at gmail.com
Tue May 15 09:07:19 CEST 2007

           I am kind of stuck with this problem for many days. I would
really appreciate the person who helps me in solving this problem.
Here is how I am stuck..
    I have files named 'x.pdb', 'y.pdb',..... in one directory. I am
using python to read the files in that directory and do a system
operation on each of the file using os.system. When I use this, it
always gives an error saying 'could not read the file'.
       I use a for loop to pass each file to the executable. The
problem comes in the identification of this file by system. To make
you clear here is the rough code I was trying to use.

import sys,os,tempfile,shutil
Pdbs = os.listdir(os.getcwd())
for Pdb in Pdbs:
    os.system("dsspcmbi -v Pdb temp1")

I will have to process that temp1 file after I get the output from the
executable 'dsspcmbi'. The system is not recognising file name Pdb.
Please tell me how can I obviate this problem.
Thanks in advance.....


More information about the Tutor mailing list