I'm probably doing something very silly and basic, but I just can't get this bit of code to work. I have a text file that contains a list of more text files (log files) with the full path for them. I want to open the first file, grab the list and then open each in turn (ultimately to do a search within each for errors) and then close them. The problem I am having is that I can't get the data from the newly opened secondary files to display.
Text file 1 (logs.txt) :
//server-1/program/data/instances/devapp/log/audit.log
//server-2/program/data/instances/devapp/log/bizman.db.log
The code I am trying to run:
import os
logdir = '/cygdrive/c/bob/logs.txt'
load_log_file = open (logdir, 'r')
read_log_file = load_log_file.readlines ()
def txt_search (read_log_file) :
for entry in read_log_file :
view_entry = open (entry, 'a+wb')
print view_entry
print txt_search (read_log_file)
The output looks like the following:
$ python log_4.py
<open file '//server-1/program/data/instances/devapp/log/audit.log
', mode 'a+wb' at 0xfff3c180>
<open file '//server-2/program/data/instances/devapp/log/bizman.db.log
', mode 'a+wb' at 0xfff3c1d8>
None
Any help would be greatly appreciated as I'm getting to the point of pulling my hair out!
Many thanks,
Bob