As background, I have created a list with elements of different filenames with their full path (/.../filea.dat) called fileList, it is of variable length. It has the form fileList = ['/../filea.dat', '/../fileb.dat'].
I would like to execute a subprocess command on every file in that list of files, then later analyze the components of each of the files (and generated new files) separately.
for i, elem in enumerate(fileList):
hexed = fileList[i]
subprocess.Popen("hexdump " + hexed + " > hexed.dat", shell=True)
with open("hexed.dat", "r") as f:
for line in f:
if "statement" in line:
value = "examplevalue"
if value == "examplevalue"
other subprocess statements that create a file that will again be used later
Right now I have a TypeError: cannot concatenate 'str' and 'list' objects. Let me know if I'm on the right track with this method approach as well.
Please let me know if I need to provide additional clarification; I tried to simplify to the basics as the other details aren't important to the issue.
TypeErrorthen ask about theTypeError(though the error message seems pretty clear. edit your question and add the complete traceback). Thus your question might be useful to somebody else too. If you want to know how to read a subprocess output line by line then ask about that (though there are many existing questions already). If you want to know how to hexlify a file in Python; you can ask about it too as a separate question (you don't need to runhexdump) Try to limit your questions to a single issue per question.