expect4j

A Java implementation of the standard Expect library

License

License

The Apache Software License, Version 2.0
GroupId

GroupId

com.github.cverges
ArtifactId

ArtifactId

expect4j
Last Version

Last Version

1.9
Release Date

Release Date

Type

Type

jar
Description

Description

expect4j
A Java implementation of the standard Expect library
Project URL

Project URL

http://github.com/cverges/expect4j
Source Code Management

Source Code Management

http://github.com/cverges/expect4j

Download expect4j

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.cverges/expect4j/ -->
<dependency>
    <groupId>com.github.cverges</groupId>
    <artifactId>expect4j</artifactId>
    <version>1.9</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.cverges/expect4j/
implementation 'com.github.cverges:expect4j:1.9'
// https://jarcasting.com/artifacts/com.github.cverges/expect4j/
implementation ("com.github.cverges:expect4j:1.9")
'com.github.cverges:expect4j:jar:1.9'
<dependency org="com.github.cverges" name="expect4j" rev="1.9">
  <artifact name="expect4j" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.cverges', module='expect4j', version='1.9')
)
libraryDependencies += "com.github.cverges" % "expect4j" % "1.9"
[com.github.cverges/expect4j "1.9"]

Dependencies

compile (5)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.12
org.apache.servicemix.bundles : org.apache.servicemix.bundles.oro jar 2.0.8_6
com.jcraft : jsch jar 0.1.53
commons-net : commons-net jar 3.3
net.sourceforge.tcljava » com.springsource.tcl.lang.jacl jar 1.4.1

test (5)

Group / Artifact Type Version
org.hamcrest : hamcrest-core jar 1.3
org.hamcrest : hamcrest-library jar 1.3
junit : junit jar 4.12
org.apache.logging.log4j.adapters : slf4j-impl jar 2.0-beta2
org.apache.commons : commons-lang3 jar 3.4

Project Modules

There are no modules declared in this project.

Expect4J

Overview

A powerful feature of Tcl has always been its integration with the Expect library (http://expect.nist.gov). As Tcl has been ported to the Java platform (http://tcljava.sourceforge.net/) certain C-based libraries have been left behind. Expect4j is an attempt to rewrite Expect in Java and provide bindings to the TclJava interpreter. The goal is to be able to port existing Tcl code bases that use Expect directly to Java without changes. The current version has successfully run a 10,000 line Tcl script which heavily depends on Expect for it operation.

Expect is the kitchen sink of IO control. It supports control of processes and sockets, and a complex method of match multiple patterns at the same time. These are needed in some applications, but it complicates the API a tad. Especially when it used in Java which doesn't support closures natively. There are other libraries which offer a more concise API, e.g. enchanter (http://code.google.com/p/enchanter/). enchanter is a very good library and it is highly recommended for automating ssh/telnet sessions. But when Expect syntax is needed, Expect4j is the way to go.

Excellent article on using expect4j: http://nikunjp.wordpress.com/2011/07/30/remote-ssh-using-jsch-with-expect4j/

Getting Started

Pre-requisites:

  • Maven 3

Build instructions:

#!/bin/bash

# Checkout the repository
git clone https://github.com/cverges/expect4j.git

# Change to the workspace
cd expect4j/

# Build everything via maven
mvn clean install

Questions?

Have questions about Expect4J? Please join our users group at https://groups.google.com/forum/#!forum/expect4j-users to ask your questions and get help from other Expect4J users.

Copyright and Licensing

Copyright © 2007 Justin Ryan
Copyright © 2013 Chris Verges <[email protected]>

Licensed under the terms of the Apache Public License v2.0.

Versions

Version
1.9
1.8
1.7-RELEASE
1.7