Struct mini_telnet::Telnet [−][src]
pub struct Telnet { /* fields omitted */ }Implementations
Create a TelnetBuilder
Login remote telnet daemon, only retry one time.
Examples
let mut client = Telnet::builder()
.prompt("username@hostname:$ ")
.login_prompt("login: ", "Password: ")
.connect_timeout(Duration::from_secs(3))
.connect("192.168.0.1").await?;
match client.login("username", "password").await {
Ok(_) => println!("login success."),
Err(e) => println!("login failed: {}", e),
};Execute command, and filter it input message by line count.
Examples
assert_eq!(telnet.execute("echo 'haha'").await?, "haha\n");All echoed content is returned when the command is executed.(Note that this may contain some useless information, such as prompts, which need to be filtered and processed by yourself.)
Examples
assert_eq!(
"echo 'haha'\nhaha\n",
telnet.normal_execute("echo 'haha'").await?
);