You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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
then I used your trick of 'Thread.sleep(2 * 1000);'
thanks a lot.
The text was updated successfully, but these errors were encountered: