Crates.io | cmlterm |
lib.rs | cmlterm |
version | 0.6.3 |
source | src |
created_at | 2021-05-30 21:41:42.420523 |
updated_at | 2021-05-30 21:41:42.420523 |
description | A command-line tool to connect to Cisco device consoles (with basic scripting support) within Cisco Modeling Labs (CML), formerly VIRL2. |
homepage | https://github.com/chrismooredev/cml-rs/tree/main/cmlterm |
repository | https://github.com/chrismooredev/cml-rs |
max_upload_size | |
id | 403963 |
size | 218,129 |
cmlterm
A command-line interface to CML devices.
Detailed help can be accessed with cmlterm --help
Line numbers are inferred to line 0, add /<line num>
to the end of the device path, if needed.
Open a device by ID
cmlterm open /abcde/n2
Or, by name:
cmlterm open "/3-Site VPN/FW2"
Uses three environment variables:
CML_HOST
: An IP address or hostname where the CML instance can be accessed.CML_USER
: The username to sign into CML withCML_PASS64
: A base-64'd version of the user's password (preferred, though should not be counted on for security)CML_PASS
: A plaintext version of the user's password (not recommended)bash
-only, though PRs are encouragedPre-built binaries are not currently provided on Github.
cmlterm
can then be installed with:cargo install cmlterm --git https://github.com/csm123199/cml-rs --branch main
For bash autocompletion, you can execute the completion wrapper in your shell. You can have it within any new user shells by adding it to your .profile:
echo 'source <(cmlterm --completions bash)' >> .profile
Commands can be piped in (specifically, input is not an interactive tty), separated by lines. Each line is sent to the device sequentially, and by default, each line waits for the next prompt to show before executing, to prevent commands dissappearing. The script is considered to end after stdin is closed and the next prompt shows. Piped input supports the following prefixes to change this behavior: (use a backslash before them to use these as literal line prefixes)
~
will not wait for the next prompt before sending. This may be helpful for automating interactive commands.`asd`
) will wait for the quoted string to appear (specifically within the last 256 bytes of terminal output) before sending the line.These control commands can be stacked to interact with each other, each are put before the beginning of the line, sequentially. If you wish to start a line with one of these characters, escape it with a backslash. Backslashes without any of the below characters following them are sent literally. If a line starting with these control sequences does not parse properly, it will be sent literally.
~
- do not wait for the next prompt before sending the command. (Takes precedence over timeout behavior)
!
- do not emit a newline at the end of the line
`64:text`
- within a rolling buffer of the last N bytes, wait until the specified text appears
%20000%
- change the default timeout to the specified number of milliseconds, for this command. If the timeout passes without either a prompt or expected text, the line will be send anyway.
Anything dynamic or more interesting than that may need to wrap cmlterm
inputs/outputs to adjust the input script. If this is done, you may want to visit the (WIP) cmlscript
binary within this same project for richer device information, and easier terminal multiplexing.