libexpect-0.1.0: Library for interacting with console applications via pseudoterminals.

System.Expect.ExpectInterface

Description

Provides a thin wrapper for the FFI bindings to libexpect contained in System.Expect.ExpectBindings.

Synopsis

Documentation

data ExpectType Source

Denotes how a case's pattern is treated.

Constructors

ExpExact

Match against pattern exactly.

ExpRegex

Compile the pattern string to a regex and match.

ExpGlob

Pattern string is glob style.

ExpNull 

data ExpectCase Source

Defines a case to match against.

Constructors

ExpectCase 

Fields

expectPattern :: String

Pattern to match against.

expectType :: ExpectType

Type of pattern contained in the case.

expectValue :: Int

The value to return if the case is matched.

data ExpectProc Source

Proc created by spawnExpect. Contains both the CFile pointer and a Haskell handle, so the translation needs only be done once.

Constructors

ExpectProc 

Fields

expectFilePtr :: Ptr CFile

Gets the pointer to the expect process file handle.

expectHandle :: Handle

Gets a Handle to the expect process.

muteExpect :: IO ()Source

Child process does not echo output to stdout.

unmuteExpect :: IO ()Source

Child process echoes output to stdout.

spawnExpectSource

Arguments

:: String

The command to be processed. eg. adduser bob

-> IO ExpectProc

Expect process.

Spawn a new expect process, running a specified program.

expectCasesSource

Arguments

:: ExpectProc

The process to expect on.

-> [ExpectCase]

The cases to match against.

-> IO (Maybe Int)

Nothing if there are no matches (timeout / EOF), the value field of the case that matched.

expectExactSource

Arguments

:: ExpectProc

The process to expect on.

-> String

The pattern.

-> IO (Maybe Int)

See expectCases.

Expect a single case with a type of ExpExact.

expectRegexSource

Arguments

:: ExpectProc

The process to expect on.

-> String

The pattern.

-> IO (Maybe Int)

See expectCases.

Expect a single case with a type of ExpExact.

expectMultipleSource

Arguments

:: ExpectProc

The process to expect on.

-> [String]

The patterns.

-> ExpectType

The type of the pattern.

-> IO (Maybe Int)

See expectCases.

Expect multiple cases of a given type.

sendLineSource

Arguments

:: ExpectProc

The process.

-> String

The line to send, without the '\n'

-> IO () 

Send a line of input to the process.