expectj

how to implement expect “interact” command using java

百般思念 提交于 2019-12-12 08:44:56
问题 I want to implement the expect "interact" command using java. In expect, it's possible to open an ssh session, authenticate and, then, use the "interact" command to give the control back to the user. Is that possible with java? I've tried with expectJ, expect4J and expectForJava but there's little documentation and almost no examples of how to do this. TIA. Update: for "interact" command reference, please check this out: http://wiki.tcl.tk/3914 "Interact is an Expect command which gives

How to run Unix shell script in a java code using ExpectJ tool?

旧城冷巷雨未停 提交于 2019-12-11 06:52:22
问题 This is my hello.sh shell script VALID_NAME="abcd" echo "Name: " read name if [ "$name" == $VALID_NAME ]; then echo "correct" else echo "unexpected input" fi ======================================================== This is my Java code import java.io.IOException; import expectj.*; public class Trial { public static void main(String[] args) { ExpectJ exp = new ExpectJ(); String command = "sh /root/Desktop/hello.sh"; Spawn s; try { s = exp.spawn(command); s.expect("Name: "); s.send("abcd");

Java library to run multiple unrelated commands on a remote server via ssh

倾然丶 夕夏残阳落幕 提交于 2019-11-29 16:05:11
My Java application has to work like this: User select bash commands in GUI and press "send." Application return distinct and independent answers for each command (e.g. we could store them in different files). Commands each run interactively, not in a batch (it can't be something like "ls\n pwd \n" etc) After each command, the application will check if the results are ok. If so, it will send the next command. We need to execute su <user> on the remote host. This will be a plugin for a bigger app, so answers like "try something else" (i.e. RPC, web services) will not help me :( As far as i

Java library to run multiple unrelated commands on a remote server via ssh

坚强是说给别人听的谎言 提交于 2019-11-28 09:54:55
问题 My Java application has to work like this: User select bash commands in GUI and press "send." Application return distinct and independent answers for each command (e.g. we could store them in different files). Commands each run interactively, not in a batch (it can't be something like "ls\n pwd \n" etc) After each command, the application will check if the results are ok. If so, it will send the next command. We need to execute su <user> on the remote host. This will be a plugin for a bigger