Last active
January 15, 2025 08:31
-
-
Save BenjiTrapp/84e77b546229e0d7c36b3a5e1426a70e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import logging | |
| import sys | |
| from subprocess import call | |
| from os import environ, uname | |
| from time import gmtime | |
| user = environ.get("SUDO_USER", environ.get("USER")) | |
| log_file = environ["LOG_HOME"] + "/.command_wrapper.log" | |
| logging.basicConfig( | |
| level=logging.DEBUG, | |
| filename=log_file, | |
| filemode="a+", | |
| format="%(asctime)s " + uname()[1] + " - " + user + " - %(message)s", | |
| datefmt='%Y-%m-%dT%H:%M:%SZ' | |
| ) | |
| logging.Formatter.converter = gmtime | |
| logger = logging.getLogger("tool_logger") | |
| tool_name = sys.argv[1] if len(sys.argv) > 1 else "unknown" | |
| logger.debug(f"Tool: {tool_name} - Command: {' '.join(sys.argv[1:])}") | |
| call(sys.argv[1:]) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chmod +x command_wrapper.py
./command_wrapper.py <Ihr_Befehl>
./command_wrapper.py curl https://example.com