I am trying to wrap rsync with java and I am having difficulty with interactive login. I can get the unix command-line utility expectto work, but I cannot figure out what the equivalent of java is ExpectJ. Here is my current code:
import java.io.IOException;
import expectj.ExpectJ;
import expectj.Spawn;
public class ExpectjTest {
public static void main(String[] args) throws IOException {
String mypassword= "example";
String cmd = "rsync -e ssh --list-only --recursive user@host:~/\n";
ExpectJ expectinator = new ExpectJ();
Spawn rsync = expectinator.spawn("/bin/bash");
try {
rsync.send(cmd);
rsync.expect("password:",2);
rsync.send(mypassword+"\n");
rsync.expectClose();
} catch (Exception e) {
e.printStackTrace();
}
}
}
When I run this, I get an error message:
ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
Permission denied (gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive).
, ssh , rsync java. script expect . , , , Java-. ssh, , JSch, java rsync, .
!