ExpectImpl

ExpectImpl spawns a process in a Spawn object. You then call expect("desired output"); sendLine("desired Input"); to interact with said process

Constructors

this
this(string cmd, OutputRange sink)

Constructs an Expect that runs cmd with no args

this
this(string cmd, string[] args, OutputRange sink)

Constructs an Expect that runs cmd with args On linux, this passes the args with cmd on front if required On windows, it passes the args as a single string seperated by spaces

Destructor

~this
~this()

Calls the spawns cleanup routine.

Members

Functions

expect
int expect(string toExpect)

Expects toExpect in output of spawn within Spawns timeout

expect
int expect(string toExpect, Duration timeout)

Expects toExpect in output of spawn within custom timeout

read
void read(Duration timeToWait = 150.msecs)

Reads data from the spawn This function will sleep for timeToWait' Duration if nothing was read first time timeToWait is 50.msecs by default

readAllAvailable
void readAllAvailable()

Reads all available data. Ends when subsequent reads dont increase length of allData

send
void send(string command)

Sends command to the pty

sendLine
void sendLine(string command)

Sends a line to the pty. Ensures it ends with newline

Properties

after
string after [@property getter]

Reads and then returns all data after the last succesfull expect. WARNING: May block if spawn is constantly writing data

before
string before [@property getter]

Returns all data before the last succesfull expect

timeout
Duration timeout [@property setter]

Sets the default timeout

timeout
long timeout [@property setter]

Sets the timeout to t milliseconds

timeout
auto timeout [@property getter]

Returns the timeout

Meta