Hello, I am using os.popen repeatedly to run Unix shell commands within my Python program. To be more specific, I am running in a loop which could iterate as many times as there are lines in an input file - in this example, close to 150 iterations. Each loop has two calls to os.popen. It works fine for the first few loops and it stops with the following error message:
IOError: [Errno 4] Interrupted system call I read about os.popen in http://docs.python.org/2/library/subprocess.html#subprocess.Popen and used the "buffer" argument to specify 4096 as the buffer size: os.popen(command, "r", 4096) This time it probably ran for a few more iterations than before and stopped with the same error message. This time it also output the following messages: IOError: [Errno 4] Interrupted system call Attribute not found in file (tsk_fs_attrlist_get: Attribute 128 not found) Attribute not found in file (tsk_fs_attrlist_get: Attribute 128 not found) Attribute not found in file (tsk_fs_attrlist_get: Attribute 128 not found) It always seems to error at the following line: "part2 = f.read()" in the code-snippet below, after a few iterations. Does popen use any system resources that need to be closed/released after each execution? I didn't find any such information in the document though. for i in range(0, length): if (self.fiDictList[i]['filename'] == filename): <snip> mmls_cmd = "mmls -i " + imgtype +" "+image +" | grep \"02:\"" # f = os.popen(mmls_cmd) <<< Original line f = os.popen(mmls_cmd, 'r', 4096) part2 = f.read() # <<<<<< This is where it shows error after getting here 4 times. part2_list = part2.split() part2_start = part2_list[2] <snip> if (redirect_file == True): icat_cmd = "icat -o "+part2_start+ " "+ image + " " + self.fiDictList[i]['inode'] + ' > ' + outfile print(">> D: Executing iCAT command: ", icat_cmd) f2 = os.popen(icat_cmd) else: <snip> return I am not sure where I am going wrong. Isn't the way I am reading the popen's output correct? But if so, why does it work for the first few iterations? Any tips appreciated. Thanks, in advance. -SM
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor