Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Sockets and Internet Protocols and the fly likes Running expect4j in an SSH environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Running expect4j in an SSH environment" Watch "Running expect4j in an SSH environment" New topic

Running expect4j in an SSH environment

Anthony Schmitt
Ranch Hand

Joined: Nov 17, 2009
Posts: 37
I'm trying to login to SSH normally, then send six digits to my server, get a response, run expect4j code that matches regex and responds.

My code is almost working, save for that fact that my six digits and following response are being processed by my later expect4j code, and I don't know why.

This is the last line that gets processed before it hands off:
expect.expect("\r\nDestination: ", loginClosure);

Alexey Gavrilov

Joined: Jan 16, 2014
Posts: 1
Self-promoting yet another Expect library for Java - Here is an example on how to talk to a public SSH service:
subject: Running expect4j in an SSH environment
Similar Threads
Invoking unix shell commands from java.
jcraft.jsch problem
Can't connect to ssh server using jsch or sshtools -- OpenSSL misconfiguration or coding error?
Closing SSH connection kill deamon
SSH port forwarding is not working