Execute shell code and return the output as a string.
(command: str)
| 10 | |
| 11 | |
| 12 | def execute(command: str) -> str: |
| 13 | """Execute shell code and return the output as a string.""" |
| 14 | try: |
| 15 | # Use shell=True to properly handle shell operators like && |
| 16 | result = subprocess.run( |
| 17 | command, |
| 18 | shell=True, |
| 19 | capture_output=True, |
| 20 | text=True, |
| 21 | ) |
| 22 | return result.stdout + result.stderr |
| 23 | except subprocess.SubprocessError as e: |
| 24 | return str(e) |
no outgoing calls