dexpect 0.0.3

A D implementation of the expect tool.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

D Implementation of the Expect framework (http://expect.sourceforge.net/)

Will run on both linux and windows - though hasnt been vigorously tested on either yet. Can be used as a standalone appliction or as a library as part of your app.

Note: This is very early days and this lib will probably change quite a lot!

To build the standalone app, clone this repo and run:

<br>


Add it to your dub.json to use it from D code.<br>
Sample use cases:<br>
Linux

Expect e = new Expect("/bin/sh"); e.expect("$"); e.sendLine("whoami"); e.expect("$"); e.sendLine("exit"); e.readAllAvailable; // reads until the subprocess stops writing writefln("Before: %s", e.before); // will print everything before the last expect ('$' in this case) writefln("After: %s", e.after); // will print the last expect + everything after it

Windows

Expect e = new Expect(C:\Windows\System32\cmd.exe); e.expect(">"); e.sendLine("echo %USERNAME%"); e.expect(">"); e.sendLine("exit"); e.readAllAvailable; // reads until the subprocess stops writing writefln("Before: %s", e.before); // will print everything before the last expect ('$' in this case) writefln("After: %s", e.after); // will print the last expect + everything after it


TODOs:

-> Implement an expect(string[] toExpect) method, that returns an int representing the index of the array which was matched.
   This will allow int idx = expect(["password:", "username:"]); constructs to handle multiple cases in one expect call.
    
-> Properly test, and write unittests 

-> Probably lots of other things...
Authors:
  • Colin Grogan
Dependencies:
none
Versions:
0.0.3 2015-May-24
0.0.2 2015-May-13
0.0.1 2015-May-08
~master 2018-Oct-10
~refactorSwitchBranch 2015-Jun-02
Show all 5 versions
Download Stats:
  • 0 downloads today

  • 1 downloads this week

  • 1 downloads this month

  • 316 downloads total

Score:
0.4
Short URL:
dexpect.dub.pm