def execute_cmd(cmddict):
    """
    Execute Command (execute_cmd)
    loop through dictionary, execute the commands, store the results, return updated dict

    :param cmddict: Dictionary of commands to execute and results
    :return: The command Dictionary with the commands results included
    """

    for item in cmddict:
        cmd = cmddict[item]["cmd"]
        if compatmode == 0:  # newer version of python, use preferred subprocess
            out, error = sub.Popen([cmd], stdout=sub.PIPE, stderr=sub.PIPE, shell=True).communicate()
            results = out.decode().split('\n')
        else:  # older version of python, use os.popen
            echo_stdout = os.popen(cmd, 'r')
            results = echo_stdout.read().split('\n')

        # write the results to the command Dictionary for each command run
        cmddict[item]["results"] = results

    return cmddict

    Execute Command (execute_cmd)
    loop through dictionary, execute the commands, store the results, return updated dict

    :param cmddict: Dictionary of commands to execute and results
    :return: The command Dictionary with the commands results included
    
linuxprivchecker/__init__.py