0
我想在Java中使用Expect的等價物。 這是一個簡單的代碼:ExpectJ for Telnet
public class TelnetJExpect
{
@Test
public void telnetTest()
{
ExpectJ expectinator = new ExpectJ(5);
try
{
Spawn shell = expectinator.spawn("172.17.80.161", 23);
System.out.println("\nExit: " + shell.getCurrentStandardOutContents());
shell.stop();
}
catch (Exception e)
{
e.printStackTrace();
assertTrue(false);
}
}
}
其結果是,我收到的垃圾:
ÿýÿý ÿý#ÿý'
退出:
ÿýÿý ÿý#ÿý'
不過,我得到連接,當我使用telnet從命令行。
請幫忙。