我想通过expectj(实际上是jsch)发送“su root”命令。它要求密码。有没有办法在 expectj 中处理它?
问问题
382 次
1 回答
1
ExpectJ ex = new ExpectJ(30);
Spawn spawn = ex.spawn(new SshSpawn("192.168.56.101", 22, "alice", "alicepassword"));
spawn.send("su root\n");
spawn.expect("assword");
spawn.send("yourpassword\n");
try{
spawn.interact();
}catch(NullPointerException npe){
//ignore, seems like some strange expectj bug
}
于 2013-04-02T11:33:23.963 回答