<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How To Run my Python Script Automatically Through HF in Installation</title>
    <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575663#M10896</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have 4 python scripts in HF. My plan is to run those python scripts automatically through my HF. How I would do that?&amp;nbsp; Thank you and any help will be highly appreciated.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Nov 2021 15:35:11 GMT</pubDate>
    <dc:creator>SplunkDash</dc:creator>
    <dc:date>2021-11-19T15:35:11Z</dc:date>
    <item>
      <title>How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575663#M10896</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have 4 python scripts in HF. My plan is to run those python scripts automatically through my HF. How I would do that?&amp;nbsp; Thank you and any help will be highly appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 15:35:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575663#M10896</guid>
      <dc:creator>SplunkDash</dc:creator>
      <dc:date>2021-11-19T15:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575665#M10897</link>
      <description>&lt;P&gt;You either ignore the splunk part completely and just run them as you'd run any other software from cron or make a custom splunk commands from them and schedule searches running those commands.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 15:37:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575665#M10897</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-11-19T15:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575683#M10898</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Thank you so much for your response, really appreciate it. Question is: How I would&amp;nbsp;&lt;SPAN&gt;make a custom splunk commands from them and schedule searches running those commands?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 16:19:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575683#M10898</guid>
      <dc:creator>SplunkDash</dc:creator>
      <dc:date>2021-11-19T16:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575756#M10901</link>
      <description>&lt;P class="lia-align-left"&gt;&lt;A href="https://dev.splunk.com/enterprise/docs/devtools/customsearchcommands/" target="_blank"&gt;https://dev.splunk.com/enterprise/docs/devtools/customsearchcommands/&lt;/A&gt;&lt;/P&gt;&lt;P class="lia-align-left"&gt;For scheduling you just create a report which runs - for example - once a day but don't care about the results &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Nov 2021 12:13:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575756#M10901</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-11-20T12:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575759#M10902</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Thank you so much for your reply, appreciated. Create, running, and schedule report shouldn't be an issue. But, how I include my python scripts in that report or pointing that python script from that report to run/execute. My complete python scripts is given below and using to parse files and it is located in HF. Thank you again.&lt;/P&gt;&lt;P&gt;----------------Starts------&lt;/P&gt;&lt;P&gt;import os&lt;BR /&gt;import re&lt;BR /&gt;from datetime import date&lt;BR /&gt;from striprtf.striprtf import rtf_to_text&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def getSubfolders(directory):&lt;BR /&gt;subfolders = []&lt;BR /&gt;for (dirpath, dirnames, filenames) in os.walk(directory):&lt;BR /&gt;subfolders.extend(dirnames)&lt;BR /&gt;break&lt;BR /&gt;return subfolders&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def getFiles(directory):&lt;BR /&gt;files = []&lt;/P&gt;&lt;P&gt;for (dirpath, dirnames, filenames) in os.walk(directory):&lt;BR /&gt;for file in filenames:&lt;BR /&gt;files.append(os.path.join(directory, file))&lt;BR /&gt;break&lt;/P&gt;&lt;P&gt;return files&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def make_clean_input_file(file, src):&lt;BR /&gt;lines = []&lt;BR /&gt;with open(file, 'r') as f:&lt;BR /&gt;rtf = f.read()&lt;BR /&gt;text = rtf_to_text(rtf)&lt;BR /&gt;lines.append(text)&lt;/P&gt;&lt;P&gt;out = open(os.path.join(src, file.split(".")[0] + "--CLEAN.TXT"), "w")&lt;BR /&gt;for line in lines:&lt;BR /&gt;out.write(line)&lt;BR /&gt;out.close()&lt;BR /&gt;return os.path.join(src, file.split(".")[0] + "--CLEAN.TXT")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def get_lines(input_file):&lt;BR /&gt;lines = []&lt;BR /&gt;skip_next = False&lt;BR /&gt;with open(input_file) as file:&lt;BR /&gt;file.readline()&lt;BR /&gt;file.readline()&lt;BR /&gt;while line := file.readline():&lt;BR /&gt;if "Report Generation Date" in line:&lt;BR /&gt;skip_next = True&lt;BR /&gt;pass&lt;BR /&gt;else:&lt;BR /&gt;if not skip_next:&lt;BR /&gt;lines.append(line.strip())&lt;BR /&gt;else:&lt;BR /&gt;skip_next = False&lt;/P&gt;&lt;P&gt;out = open(input_file.split('--')[0] + "--SANITIZED.txt", 'w')&lt;BR /&gt;for line in lines:&lt;BR /&gt;out.write(line + '\n')&lt;BR /&gt;out.close()&lt;BR /&gt;return lines&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def param_text(p_name, value, quotes=True):&lt;BR /&gt;text = ""&lt;BR /&gt;if not quotes:&lt;BR /&gt;text = p_name + "=" + value&lt;BR /&gt;else:&lt;BR /&gt;text = p_name + "=\"" + value + "\""&lt;BR /&gt;return text&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def format_param(param):&lt;BR /&gt;text = ''&lt;BR /&gt;words = param.split(" ")&lt;BR /&gt;for w in words:&lt;BR /&gt;if text == '':&lt;BR /&gt;text = w.upper()&lt;BR /&gt;else:&lt;BR /&gt;text = text + "_" + w.upper()&lt;BR /&gt;return text&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def get_preamble(lines):&lt;BR /&gt;preamble = []&lt;/P&gt;&lt;P&gt;for i in range(len(lines)):&lt;BR /&gt;if "Policy Checker" in lines[i]:&lt;BR /&gt;preamble.append(param_text("SOFTWARE_VERSION", lines[i].split("-")[0].strip()))&lt;BR /&gt;preamble.append(param_text("REPORT_NAME", lines[i].split("-")[1].strip()))&lt;BR /&gt;elif "Compliance Status Legend" in lines[i]: # 13 is the end of the preamble that is used&lt;BR /&gt;break&lt;BR /&gt;elif "Unique Failed Checks" in lines[i] or "Total Failed Checks" in lines[i] or "Software Version" in lines[i]:&lt;BR /&gt;pass&lt;BR /&gt;else:&lt;BR /&gt;params = lines[i].split("\t")&lt;BR /&gt;if len(params) == 1:&lt;BR /&gt;preamble.append(param_text(format_param(params[0]), ""))&lt;BR /&gt;else:&lt;BR /&gt;preamble.append(param_text(format_param(params[0]), params[1]))&lt;BR /&gt;if len(params) &amp;gt; 2:&lt;BR /&gt;print("PARAM MORE THAN 2!!!")&lt;BR /&gt;return preamble&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def get_compliance_status_descriptions(lines):&lt;BR /&gt;cs = []&lt;BR /&gt;start = -1&lt;BR /&gt;end = -1&lt;BR /&gt;for i in range(len(lines)):&lt;BR /&gt;if "BLUE\t" in lines[i]:&lt;BR /&gt;start = i&lt;BR /&gt;elif "RED\t" in lines[i]:&lt;BR /&gt;end = i+1&lt;/P&gt;&lt;P&gt;for i in range(start, end):&lt;BR /&gt;param = "COMP_STATUS_" + lines[i].split('\t')[0].upper() + "_DESC"&lt;BR /&gt;cs.append(param_text(param, lines[i].split("\t")[1].strip(' ')))&lt;/P&gt;&lt;P&gt;# POLICY LINES&lt;BR /&gt;for i in range(len(lines)):&lt;BR /&gt;if "Check Failure Details" in lines[i]:&lt;BR /&gt;brick2 = lines[i+2].split('\t')&lt;BR /&gt;cs.append(param_text('POLICY', brick2[0]))&lt;BR /&gt;cs.append(param_text('POLICY_NAME', brick2[1]))&lt;BR /&gt;cs.append(param_text('POLICY_DATE', brick2[2]))&lt;BR /&gt;return cs&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def get_test_results(lines):&lt;BR /&gt;cs = []&lt;BR /&gt;brick = lines[24].split("\t")&lt;/P&gt;&lt;P&gt;cs.append(param_text("COMPLIANCE_STATUS", brick[1]))&lt;BR /&gt;cs.append(param_text("UNIQUE_FAILS", brick[2]))&lt;BR /&gt;cs.append(param_text("TOTAL_FAILS", brick[3]))&lt;BR /&gt;cs.append(param_text("UNIQUE_ERRORS", brick[4]))&lt;BR /&gt;cs.append(param_text("TOTAL_ERRORS", brick[5]))&lt;BR /&gt;cs.append(param_text("SCORE", brick[6]))&lt;/P&gt;&lt;P&gt;prefix = "CHK_STATUS_"&lt;BR /&gt;for i in range(27, 33):&lt;BR /&gt;p_name = lines[i].split('\t')[0].replace('/', '')&lt;BR /&gt;val = lines[i].split('\t')[1]&lt;BR /&gt;cs.append(param_text(format_param(prefix + p_name), val))&lt;BR /&gt;return cs&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def get_bounds(lines, delimiter="Check Failure Details"):&lt;BR /&gt;starts = []&lt;BR /&gt;ends = []&lt;/P&gt;&lt;P&gt;for i in range(33, len(lines)):&lt;BR /&gt;if delimiter in lines[i]:&lt;BR /&gt;starts.append(i)&lt;BR /&gt;elif '____' in lines[i]:&lt;BR /&gt;ends.append(i)&lt;BR /&gt;if i &amp;lt; len(lines) - 1:&lt;BR /&gt;starts.append(i)&lt;BR /&gt;elif "RBD Tracking ID\t" in lines[i]:&lt;BR /&gt;ends.append(i)&lt;BR /&gt;# starts.append(i)&lt;BR /&gt;break&lt;BR /&gt;if len(starts) &amp;gt; len(ends):&lt;BR /&gt;ends.append(len(lines))&lt;/P&gt;&lt;P&gt;return list(zip(starts, ends))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def get_description(lines, start, delimiter):&lt;BR /&gt;true_end = -1&lt;BR /&gt;desc = ''&lt;BR /&gt;for i in range(start, len(lines)):&lt;BR /&gt;if delimiter in lines[i]:&lt;BR /&gt;true_end = i&lt;BR /&gt;break&lt;BR /&gt;if true_end == -1:&lt;BR /&gt;true_end = len(lines)&lt;BR /&gt;for i in range(start + 1, true_end):&lt;BR /&gt;desc += lines[i] + " "&lt;BR /&gt;return desc&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def get_policy(lines, bounds, prefix_num):&lt;BR /&gt;Summary = (param_text(str(prefix_num) + "_summary", ""))&lt;BR /&gt;nistPolicy = (param_text(str(prefix_num) + "_nistPolicy", ""))&lt;BR /&gt;Description = (param_text(str(prefix_num) + "_desc", ""))&lt;BR /&gt;reqSetting = (param_text(str(prefix_num) + "_reqSetting", ""))&lt;BR /&gt;extRef = (param_text(str(prefix_num) + "_extRef", ""))&lt;BR /&gt;policyID = (param_text(str(prefix_num) + "_policyID", ""))&lt;BR /&gt;appliesTo = (param_text(str(prefix_num) + "_appliesTo", ""))&lt;BR /&gt;risk = (param_text(str(prefix_num) + "_risk", ""))&lt;BR /&gt;category = (param_text(str(prefix_num) + "_category", ""))&lt;BR /&gt;checkID = (param_text(str(prefix_num) + "_checkID", ""))&lt;BR /&gt;irsPolicy = (param_text(str(prefix_num) + "_irsPolicy", ""))&lt;BR /&gt;policy_lines = []&lt;/P&gt;&lt;P&gt;for i in range(bounds[0], bounds[1]):&lt;BR /&gt;if "Summary\t" in lines[i]:&lt;BR /&gt;Summary = (param_text(str(prefix_num) + "_summary", lines[i].split('\t', 1)[1]))&lt;BR /&gt;elif "800-53A\t" in lines[i]:&lt;BR /&gt;nistPolicy = (param_text(str(prefix_num) + "_nistPolicy", lines[i].split('\t', 1)[1]))&lt;BR /&gt;elif "Description" in lines[i]:&lt;BR /&gt;d = get_description(lines, i, "Required Setting")&lt;BR /&gt;Description = (param_text(str(prefix_num) + "_desc", d))&lt;BR /&gt;elif "Required Setting" in lines[i]:&lt;BR /&gt;r = get_description(lines, i, "Actual Setting")&lt;BR /&gt;reqSetting = (param_text(str(prefix_num) + "_reqSetting", r))&lt;BR /&gt;elif "External References" in lines[i]:&lt;BR /&gt;extRef = param_text(str(prefix_num) + "_extRef", lines[i + 1])&lt;BR /&gt;elif "Policy ID\t" in lines[i]:&lt;BR /&gt;policyID = (param_text(str(prefix_num) + "_policyID", lines[i].split('\t', 1)[1]))&lt;BR /&gt;elif "Applies" in lines[i]:&lt;BR /&gt;appliesTo = (param_text(str(prefix_num) + "_appliesTo", lines[i].split('\t', 1)[1]))&lt;BR /&gt;elif "Risk\t" in lines[i]:&lt;BR /&gt;risk = (param_text(str(prefix_num) + "_risk", lines[i].split('\t', 1)[1]))&lt;BR /&gt;elif "Category\t" in lines[i]:&lt;BR /&gt;category = (param_text(str(prefix_num) + "_category", lines[i].split('\t', 1)[1]))&lt;BR /&gt;elif "Check ID\t" in lines[i]:&lt;BR /&gt;checkID = (param_text(str(prefix_num) + "_checkID", lines[i].split('\t', 1)[1]))&lt;BR /&gt;elif "IRS Policy\t" in lines[i]:&lt;BR /&gt;irsPolicy = (param_text(str(prefix_num) + "_irsPolicy", lines[i].split('\t', 1)[1]))&lt;/P&gt;&lt;P&gt;policy_lines.append(Summary)&lt;BR /&gt;policy_lines.append(nistPolicy)&lt;BR /&gt;policy_lines.append(reqSetting)&lt;BR /&gt;policy_lines.append(policyID)&lt;BR /&gt;policy_lines.append(extRef)&lt;BR /&gt;policy_lines.append(appliesTo)&lt;BR /&gt;policy_lines.append(risk)&lt;BR /&gt;policy_lines.append(irsPolicy)&lt;BR /&gt;policy_lines.append(category)&lt;BR /&gt;policy_lines.append(checkID)&lt;BR /&gt;policy_lines.append(Description)&lt;/P&gt;&lt;P&gt;return policy_lines&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def get_settings(lines, bounds, prefix_num):&lt;BR /&gt;counter = 1&lt;BR /&gt;start = -1&lt;BR /&gt;breaks = []&lt;BR /&gt;actualSetting = ''&lt;BR /&gt;moreInfo = ''&lt;BR /&gt;flag = False&lt;BR /&gt;settings = []&lt;BR /&gt;output = []&lt;/P&gt;&lt;P&gt;for i in range(bounds[0], bounds[1]):&lt;BR /&gt;if "Actual Setting" in lines[i]:&lt;BR /&gt;start = i + 1&lt;BR /&gt;break&lt;BR /&gt;if start == -1:&lt;BR /&gt;return []&lt;BR /&gt;for i in range(start, bounds[1]):&lt;BR /&gt;breaks.append(lines[i].partition('\t'))&lt;/P&gt;&lt;P&gt;for b in breaks:&lt;BR /&gt;if b[1] == '\t' and not flag:&lt;BR /&gt;actualSetting += b[0]&lt;BR /&gt;moreInfo += b[2]&lt;BR /&gt;elif b[1] == '':&lt;BR /&gt;moreInfo += b[0]&lt;BR /&gt;flag = True&lt;BR /&gt;elif b[1] == '\t' and flag:&lt;BR /&gt;settings.append([actualSetting, moreInfo])&lt;BR /&gt;actualSetting = b[0]&lt;BR /&gt;moreInfo = b[2]&lt;BR /&gt;flag = False&lt;BR /&gt;settings.append([actualSetting, moreInfo])&lt;/P&gt;&lt;P&gt;for s in settings:&lt;BR /&gt;output.append(param_text(str(prefix_num) + "_" + str(counter) + "_actualSetting", s[0].strip()))&lt;BR /&gt;output.append(param_text(str(prefix_num) + "_" + str(counter) + "_moreInfo", s[1].strip()))&lt;BR /&gt;counter += 1&lt;/P&gt;&lt;P&gt;return output&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def parse_policy(lines, bounds, prefix_num):&lt;BR /&gt;policy_lines = get_policy(lines, bounds, prefix_num) # GET the policy info lines&lt;BR /&gt;actual_Settings = get_settings(lines, bounds, prefix_num) # GET Actual Settings for the policy&lt;BR /&gt;output = []&lt;/P&gt;&lt;P&gt;for p in policy_lines:&lt;BR /&gt;output.append(p)&lt;BR /&gt;for a in actual_Settings:&lt;BR /&gt;output.append(a)&lt;/P&gt;&lt;P&gt;return output&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def get_policies(lines):&lt;BR /&gt;bounds = get_bounds(lines)&lt;BR /&gt;counter = 1&lt;BR /&gt;output = []&lt;/P&gt;&lt;P&gt;for i in range(len(bounds)):&lt;BR /&gt;policy = parse_policy(lines, bounds[i], counter)&lt;BR /&gt;for p in policy:&lt;BR /&gt;output.append(p)&lt;BR /&gt;counter += 1&lt;/P&gt;&lt;P&gt;return output&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def get_rbd(lines):&lt;BR /&gt;start = -1&lt;BR /&gt;end = len(lines) - 1&lt;BR /&gt;comment = ''&lt;BR /&gt;rbd = []&lt;/P&gt;&lt;P&gt;for i in range(len(lines)):&lt;BR /&gt;if "RBD Tracking ID" in lines[i]:&lt;BR /&gt;start = i + 1&lt;BR /&gt;break&lt;BR /&gt;if start == -1:&lt;BR /&gt;return []&lt;BR /&gt;for i in range(start, len(lines)):&lt;BR /&gt;if i == start:&lt;/P&gt;&lt;P&gt;rbd.append(param_text("RBD_TrackingID", lines[i].split('\t')[0]))&lt;BR /&gt;rbd.append(param_text("RBD_Approver", lines[i].split('\t')[1]))&lt;BR /&gt;rbd.append(param_text("RBD_POAM_Number", ''))&lt;BR /&gt;comment = lines[i].split('\t')[2]&lt;BR /&gt;rbd.append(param_text("RBD_ApprovalDate", lines[i].split('\t')[3]))&lt;BR /&gt;rbd.append(param_text("RBD_ExpirationDate", "none"))&lt;BR /&gt;else:&lt;BR /&gt;if "________________________________________________________________________________________________" not in \&lt;BR /&gt;lines[i]:&lt;BR /&gt;comment += lines[i].strip()&lt;BR /&gt;rbd.append(param_text("RBD_Comment", comment))&lt;/P&gt;&lt;P&gt;return rbd&lt;/P&gt;&lt;P&gt;def nu_TESTER(lists):&lt;BR /&gt;for i in range(len(lists)):&lt;BR /&gt;for j in range(len(lists[i])):&lt;BR /&gt;print(lists[i][j])&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def parse_input(input_file):&lt;BR /&gt;lines = get_lines(input_file)&lt;BR /&gt;preamble = get_preamble(lines) # lines start to 13 used;&lt;BR /&gt;comp_status = get_compliance_status_descriptions(lines) # lines 16 thru 19&lt;BR /&gt;compliance_summary = get_test_results(lines) # lines 24 to 32&lt;BR /&gt;policies = get_policies(lines)&lt;BR /&gt;rbd = get_rbd(lines)&lt;BR /&gt;parts = [preamble, compliance_summary, comp_status, policies, rbd]&lt;BR /&gt;output = []&lt;BR /&gt;for p in parts:&lt;BR /&gt;for line in p:&lt;BR /&gt;output.append(line)&lt;/P&gt;&lt;P&gt;return output&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;def main():&lt;BR /&gt;today = date.today()&lt;BR /&gt;date_prefix = today.strftime("%Y-%m-%d_")&lt;BR /&gt;all_files = []&lt;BR /&gt;subfolders = []&lt;BR /&gt;# source_folder = input("Please enter source folder for processing (root):")&lt;BR /&gt;# Linux&lt;BR /&gt;source_folder = r"/opt/splunk/etc/apps/SourceFiles/"&lt;BR /&gt;subfolders.extend(getSubfolders(source_folder))&lt;BR /&gt;for folder in subfolders:&lt;BR /&gt;temp = getFiles(os.path.join(source_folder, folder))&lt;BR /&gt;# print(temp)&lt;BR /&gt;for t in temp:&lt;BR /&gt;if t[-4:] == ".rtf" and "Computer_Summary" in t and t[0:2] != "~$":&lt;BR /&gt;all_files.append(t)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;for file in all_files:&lt;BR /&gt;print("current file=", file)&lt;BR /&gt;input_file = make_clean_input_file(file, source_folder)&lt;BR /&gt;output = parse_input(input_file)&lt;BR /&gt;outfile = input_file.split('--')[0] + '.parsed'&lt;BR /&gt;print('Saving output to:', outfile)&lt;/P&gt;&lt;P&gt;# add date prefix&lt;BR /&gt;# outfile = outfile.rsplit('\\', 1)[0] + "\\" + date_prefix + outfile.rsplit('\\', 1)[1].split('--')[0]&lt;BR /&gt;# Linux pathing:&lt;BR /&gt;outfile = outfile.rsplit('/', 1)[0] + "/" + date_prefix + outfile.rsplit('/', 1)[1].split('--')[0]&lt;/P&gt;&lt;P&gt;# Save output&lt;BR /&gt;out = open(outfile, 'w')&lt;BR /&gt;for o in output:&lt;BR /&gt;out.write(o + '\n')&lt;BR /&gt;out.close()&lt;/P&gt;&lt;P&gt;# remove clean input file&lt;BR /&gt;os.remove(input_file)&lt;BR /&gt;os.remove(input_file.split('--')[0] + '--SANITIZED.txt')&lt;BR /&gt;return 0&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if __name__ == "__main__":&lt;BR /&gt;main()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------End-------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Nov 2021 12:45:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575759#M10902</guid>
      <dc:creator>SplunkDash</dc:creator>
      <dc:date>2021-11-20T12:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575767#M10903</link>
      <description>&lt;P&gt;Look at the docs I pointed you to. I haven't done it myself but it involves creating some config files so that splunk understands how to interface with your script.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Nov 2021 14:56:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575767#M10903</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-11-20T14:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575768#M10904</link>
      <description>Probably the easiest way is to create TA which contains those as inputs. Then schedule those with required frequency.</description>
      <pubDate>Sat, 20 Nov 2021 16:04:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575768#M10904</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2021-11-20T16:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575769#M10905</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Yes, I agree .....if we can create a TA...that would be the easiest way ... But, what is&amp;nbsp; meant by "&lt;SPAN&gt;contains those as inputs&lt;/SPAN&gt;"?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Nov 2021 16:11:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575769#M10905</guid>
      <dc:creator>SplunkDash</dc:creator>
      <dc:date>2021-11-20T16:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575771#M10906</link>
      <description>You could create a scripted input there. &lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/latest/AdvancedDev/ScriptSetup" target="_blank"&gt;https://docs.splunk.com/Documentation/SplunkCloud/latest/AdvancedDev/ScriptSetup&lt;/A&gt;&lt;BR /&gt;It could return the status of execution as output. No need to send anything special.&lt;BR /&gt;R. Ismo</description>
      <pubDate>Sat, 20 Nov 2021 20:07:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575771#M10906</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2021-11-20T20:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575774#M10907</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Thank you so much for your support. But, it might be a little complicated to implement that approach in my context. If possible please let me know how&amp;nbsp; I would proceed to run those Python scripts as Cron jobs. Thank you again.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Nov 2021 04:53:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575774#M10907</guid>
      <dc:creator>SplunkDash</dc:creator>
      <dc:date>2021-11-21T04:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575780#M10908</link>
      <description>&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.3/Admin/Inputsconf" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.3/Admin/Inputsconf&lt;/A&gt; You should look script and there interval. That will helps you to do scheduling part without adding it HFs cron. It just use splunkd to do it.</description>
      <pubDate>Sun, 21 Nov 2021 13:06:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575780#M10908</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2021-11-21T13:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575795#M10909</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;Thank you so much, it's an excellent resource. But, just wanted make sure we are on the same page, the main objective of those scripts are to parse the source files which are manually placed on the Linux server where HF has been installed, not more than that at this stage. Here is the Cron jobs (please see below) I consider to use for running my 4 python scripts. Now question is, how I would place these Cron tasks in a file (or in a place) that it would run those python scripts automatically to parse those files. Thank you again&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;10 23 * * * /opt/splunk/etc/apps/python-scripts/script1.py&lt;/P&gt;&lt;P&gt;12 23 * * * /opt/splunk/etc/apps/python-scripts/script2.py&lt;/P&gt;&lt;P&gt;14 23 * * * /opt/splunk/etc/apps/python-scripts/script3.py&lt;/P&gt;&lt;P&gt;16 23 * * * /opt/splunk/etc/apps/python-scripts/script4.py&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Nov 2021 18:34:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/575795#M10909</guid>
      <dc:creator>SplunkDash</dc:creator>
      <dc:date>2021-11-21T18:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: How To Run my Python Script Automatically Through HF</title>
      <link>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/576153#M10930</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;You can run those by splunk even you are not getting data into splunk via those. Just see these docs:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/AdvancedDev/ScriptSetup" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/AdvancedDev/ScriptSetup&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://dev.splunk.com/enterprise/docs/developapps/manageknowledge/custominputs/scriptedinputsexample/" target="_blank"&gt;https://dev.splunk.com/enterprise/docs/developapps/manageknowledge/custominputs/scriptedinputsexample/&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Then it's totally another story is Splunk the correct or best tool to do this or should you use something else to manage your batch jobs. But it's out of scope of this discussion.&lt;/P&gt;&lt;P&gt;r. Ismo&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 09:23:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/How-To-Run-my-Python-Script-Automatically-Through-HF/m-p/576153#M10930</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2021-11-24T09:23:53Z</dc:date>
    </item>
  </channel>
</rss>

