<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def execd_run(command, execd_dir=None, die_on_error=True, stderr=subprocess.STDOUT):
 """Run command for each module within execd_dir which defines it."""

    for submodule_path in execd_submodule_paths(command, execd_dir):
        try:
            subprocess.check_output(submodule_path, stderr=stderr,
                                    universal_newlines=True)
        except subprocess.CalledProcessError as e:
            hookenv.log("Error ({}) running  {}. Output: {}".format(
                e.returncode, e.cmd, e.output))
            if die_on_error:
                sys.exit(e.returncode)