File size: 529 Bytes
5f83674
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import subprocess

class BashEvaluator:
    """
    Evaluates shell/Bash commands in a safe subprocess.
    """
    def __init__(self, name="bash_evaluator"):
        self.name = name

    def evaluate(self, command_str):
        try:
            result = subprocess.run(command_str, shell=True, capture_output=True, text=True, timeout=5)
            return {"success": result.returncode == 0, "stdout": result.stdout, "stderr": result.stderr}
        except Exception as e:
            return {"success": False, "error": str(e)}