Build Status crates.io

Documentation (Development)

The goal is to offer a similar set of functionality as pexpect.

Basic usage

Add this to your Cargo.toml

toml [dependencies] rexpect = "0.1"

Simple example for interacting via ftp:

```rust extern crate rexpect;

use rexpect::spawn; use rexpect::errors::*;

fn doftp() -> Result<()> { let mut p = spawn("ftp speedtest.tele2.net", Some(2000))?; p.expregex("Name \(.*\):")?; p.sendline("anonymous")?; p.expstring("Password")?; p.sendline("test")?; p.expstring("ftp>")?; p.sendline("cd upload")?; p.expstring("successfully changed.\r\nftp>")?; p.sendline("pwd")?; p.expregex("[0-9]+ \"/upload\"")?; p.sendline("exit")?; p.expeof()?; Ok(()) }

fn main() { doftp().unwrapor_else(|e| panic!("ftp job failed with {}", e)); } ```

Example with bash

```rust extern crate rexpect; use rexpect::spawn_bash; use rexpect::errors::*;

fn run() -> Result<()> { let mut p = spawnbash(None)?; p.execute("ping 8.8.8.8")?; p.sendcontrol('z')?; p.waitforprompt()?; p.execute("bg")?; p.waitforprompt()?; p.execute("sleep 1")?; p.waitforprompt()?; p.execute("fg")?; p.sendcontrol('c')?; p.expstring("packet loss")?; Ok(()) }

fn main() { run().unwraporelse(|e| panic!("bash process failed with {}", e)); } ```

Project Status

What already works:

What does not yet work:

What will probably never be implemented

Design decisions