How it works...

We begin by importing the required libraries for this script, including the newly installed splunklib. To prevent unnecessary errors arising due to user ignorance, we use the sys library to determine the version of Python executing the script and raise an error if it is not Python 2.

from __future__ import print_functionfrom argparse import ArgumentParser, ArgumentErrorfrom argparse import ArgumentDefaultsHelpFormatterimport splunklib.client as clientimport splunklib.results as resultsimport osimport sysimport csvif sys.version_info.major != 2:    print("Invalid python version. Must use Python 2 due to splunk api "          "library")

The next logical block to develop is the recipe's command-line argument handler. As we have many options ...

Get Python Digital Forensics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.