12 lines
385 B
Python
12 lines
385 B
Python
|
import json
|
||
|
import subprocess
|
||
|
|
||
|
|
||
|
def func_run_bash(command_data: str):
|
||
|
j = json.loads(command_data)
|
||
|
command = j.get('command')
|
||
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||
|
stdout, stderr = process.communicate()
|
||
|
return_code = process.returncode
|
||
|
return stdout.decode('utf-8'), stderr.decode('utf-8'), return_code
|