Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCP Issue 1 - Non-deterministic behavior with Expect4J #1

Open
cverges opened this issue Aug 27, 2013 · 0 comments
Open

GCP Issue 1 - Non-deterministic behavior with Expect4J #1

cverges opened this issue Aug 27, 2013 · 0 comments

Comments

@cverges
Copy link
Owner

cverges commented Aug 27, 2013

Reported by [email protected], Jul 28, 2008
Expect4j is really a good project.

In following code snippet, I am trying to login to terminal server. somehow
I have to wait little bit ( 5 seconds) between 'send' and 'expect',
otherwise 'expect' function throws exception of type 'Exception'. If I
execute code in debug mode, I do not need Thread.sleep.

expect.expect("login:");

if (expect.getLastState().getMatch() == null) {
    throw new LoginFailedException("Login to NS Failed, someone is already logged in");
}

expect.send("nsroot" + "\r");

Thread.sleep(2 * 1000); //Somehow Expect4j does not work without this delay in execution.

expect.expect("Password:");

if (expect.getLastState().getMatch() == null) {
    throw new LoginFailedException("Login to NS Failed");
}

expect.send("nsroot" + "\r");

Thanks.
Jay

Jul 28, 2008 #1 [email protected]
What should I understand when 'expect' function throws exception of type
'Exception'.? I am really not able to debug this as in debug mode I do not need
Thread.sleep and expect function works fine. I am very unclear what is going on.
Thanks a lot. Hope to hear from you soon.

Thanks.
Jay

Jan 22, 2013 #2 [email protected]
Jay, you really saved my day. I was banging my head since morning to get the my code working. It was trying this tutorial http://nikunjp.wordpress.com/2011/07/30/remote-ssh-using-jsch-with-expect4j/ and it was working fine in debug mode but while running it was giving following error

        expect4j.BlockingConsumer run
        INFO: Stop Requested

then I used your trick of 'Thread.sleep(2 * 1000);'
thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant