Made some chanages and now Can't remmebr what I did
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
import subprocess
|
||||
|
||||
def run_command(command: str):
|
||||
"""Executes a Linux command, waits for completion, and returns output."""
|
||||
try:
|
||||
# shell=True allows running full command strings with pipes/wildcards
|
||||
# text=True returns strings instead of bytes
|
||||
result = subprocess.run(
|
||||
command, shell=True, check=True, capture_output=True, text=True
|
||||
)
|
||||
|
||||
return {"success": True, "stdout": result.stdout, "stderr": result.stderr}
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
# Handles errors if the Linux command returns a non-zero exit code
|
||||
return {"success": False, "stdout": e.stdout, "stderr": e.stderr}
|
||||
Reference in New Issue
Block a user