From caa8b47a9fbc8a2b5f1b6a105130699905243e8f Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Wed, 25 Nov 2020 19:58:46 +0100 Subject: Added try script instead of it being in the README --- try | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 try (limited to 'try') diff --git a/try b/try new file mode 100755 index 0000000..6ae8cb9 --- /dev/null +++ b/try @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import os +import sys +import subprocess + +from src.config import MINISHELL_DIR, MINISHELL_EXEC, EXECUTABLES_PATH + + +if __name__ == "__main__": + if len(sys.argv) != 2: + print("Usage {} command".format(sys.argv[0])) + sys.exit(1) + print("=================== RUNNING " + sys.argv[1]) + process = subprocess.Popen( + [os.path.join(MINISHELL_DIR, MINISHELL_EXEC), "-c", sys.argv[1]], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + env={"PATH": EXECUTABLES_PATH, "TERM": "xterm-256color"} + ) + out, _ = process.communicate() + print(out.decode()) -- cgit