Hello,
I'm running into an odd problem - well, at least I think it's odd, but that's probably because I have a Cygwin screen burned into my retinas from staring at it for so long. When I run my script below, the output lines print twice. I'm hoping it's something simple (and yet kind of not, because then I look like a fool... oh well), but hopefully a fresh pair of eyes might be able to help me.
Oh, and please feel free to comment on how I'm removing the data - I found a QAD way, but I'm guessing there might be a better way.
-
s_fileToParse = "/opt/www/status.html"
-
s_SummaryFile = "/home/user/weeklyReport.txt"
-
l_linesToRead = []
-
i_configured = 0
-
i_down = 0
-
FILE = open(s_fileToParse,"r")
-
-
l_linesToRead = FILE.readlines()
-
-
for s_lines in l_linesToRead:
-
if s_lines.startswith("Total"):
-
# parse for number between <B> and </B>
-
s_lines = s_lines.lstrip("Total # Configured: <B>")
-
s_lines = s_lines.rstrip("</B><BR>\n")
-
i_configured = int(s_lines)
-
elif s_lines.startswith('# down:'):
-
# parse for number between <B> and </B>
-
s_lines = s_lines.lstrip('<B>')
-
s_lines = s_lines.rstrip('</z')
-
i_down = int(s_lines)
-
-
FILE.close()
-
FILE = open(s_SummaryFile,"a")
-
FILE.write("\nTotal # Configured: ")
-
FILE.write(str(i_configured))
-
FILE.write("\nTotal # Down: ")
-
FILE.write(str(i_down))
-
FILE.write("\nTotal # Reporting: ")
-
FILE.write(str(i_configured-i_down))
-
FILE.close()
-