I would like to send "su root" command via expectj (in fact it is jsch).It requests password. Is there a way to handle it in expectj ?
Asked
Active
Viewed 400 times
1 Answers
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
}