Demo: Execute bash commands.
()
| 88 | |
| 89 | |
| 90 | async def demo_bash_tool(): |
| 91 | """Demo: Execute bash commands.""" |
| 92 | print("\n" + "=" * 60) |
| 93 | print("Demo 4: BashTool - Execute bash commands") |
| 94 | print("=" * 60) |
| 95 | |
| 96 | tool = BashTool() |
| 97 | |
| 98 | # Example 1: List files |
| 99 | print("\nCommand: ls -la") |
| 100 | result = await tool.execute(command="ls -la") |
| 101 | if result.success: |
| 102 | print(f"✅ Command executed successfully") |
| 103 | print(f"Output:\n{result.content[:200]}...") |
| 104 | |
| 105 | # Example 2: Get current directory |
| 106 | print("\nCommand: pwd") |
| 107 | result = await tool.execute(command="pwd") |
| 108 | if result.success: |
| 109 | print(f"✅ Current directory: {result.content.strip()}") |
| 110 | |
| 111 | # Example 3: Echo |
| 112 | print("\nCommand: echo 'Hello from BashTool!'") |
| 113 | result = await tool.execute(command="echo 'Hello from BashTool!'") |
| 114 | if result.success: |
| 115 | print(f"✅ Output: {result.content.strip()}") |
| 116 | |
| 117 | |
| 118 | async def main(): |