run_command
Run CLI commands on PNETLab network nodes and return output. Handles telnet login and session management for efficient troubleshooting.
Instructions
Run a single CLI command on a running node and return its output.
Opens a telnet console, handles the IAC handshake, logs in if the device asks
(default admin/empty password -- pass credentials for devices that differ),
sends the command, and reads until the output goes idle (or wait_for
regex matches). The session is pooled and reused across calls; call
console_close when finished with a node.
Examples: run_command(1, "/ip address print") on a MikroTik; run_command(1, "ping 10.0.0.2 count 4", wait_for="packet-loss") ; run_command(2, "show ip interface brief") on IOS; run_command(3, "ping 10.0.0.1") on VPCS.
Gotcha: a single ? for help often does not trigger under telnet; use
run_command with the full command instead. For long-running monitors, pass
wait_for to match the final summary line.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | ||
| node_id | Yes | ||
| timeout | No | ||
| password | No | ||
| username | No | admin | |
| wait_for | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |