Crate expectrl[][src]

Expand description

Expectrl a library for running, controlling and communicating with a process.

It supports async/await. To use it you should specify a async feature.

Example

use expectrl::{spawn, Regex, Eof, WaitStatus};

let mut p = spawn("ftp speedtest.tele2.net").unwrap();
p.expect(Regex("Name \\(.*\\):")).unwrap();
p.send_line("anonymous").unwrap();
p.expect("Password").unwrap();
p.send_line("test").unwrap();
p.expect("ftp>").unwrap();
p.send_line("cd upload").unwrap();
p.expect("successfully changed.\r\nftp>").unwrap();
p.send_line("pwd").unwrap();
p.expect(Regex("[0-9]+ \"/upload\"")).unwrap();
p.send_line("exit").unwrap();
p.expect(Eof).unwrap();
assert_eq!(p.wait().unwrap(), WaitStatus::Exited(p.pid(), 0));

Modules

Structs

Eof consider a match when it’s reached a EOF.

NBytes matches N bytes.

Regex checks a match by regex.

Enums

ControlCode represents the standard ASCII control codes wiki

Possible return values from wait() or waitpid().

Traits

Needle an interface for search of a match in a buffer.

Functions

Spawn spawnes a new session.

Type Definitions