From e20daf639dd271268b172b42adc0d1b9d2103883 Mon Sep 17 00:00:00 2001 From: Alvaro Neira Ayuso Date: Fri, 27 Dec 2019 13:46:49 +0100 Subject: Add shell run and output commands Opengnsys needs a support to execute commands on the machine. This patch adds the support for executing two new commands "shell/run" and "shell/output". The first one, give us the support for executing a command in the machine and keep save in a queue the output. The second one, give us the support for sending the output from the command executed. --- src/linux/ogOperations.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/linux') diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py index e3d69e2..1502f40 100644 --- a/src/linux/ogOperations.py +++ b/src/linux/ogOperations.py @@ -14,3 +14,8 @@ def reboot(): subprocess.call('source ' + OG_SCRIPT_PATH + 'etc/preinit/loadenviron.sh; ' + OG_SCRIPT_PATH + 'scripts/reboot', shell=True) else: subprocess.call(['/sbin/reboot']) + +def execCMD(cmd): + cmds = cmd.split(" ") + result = subprocess.run(cmds, stdout=subprocess.PIPE) + return result.stdout.decode('utf-8') -- cgit v1.2.3-18-g5258