I execute some commands using SSHJ, I do this with this method:
private Command executeCommand(String command, SSHClient client) { Command commandObject = client.startSession().exec(command); commandObject.join(); return commandObject; }
It works well until I ran this command:
cd $SOLR; nohup java -Dsolr.solr.home=./solr -DSTOP.PORT=8079 -DSTOP.KEY=stopkey -jar start.jar 2> logs/solr.log &
In this case, the entire program freezes on
commandObject.join();
Of course, the process begins. It also immediately returns the same line from the shell.
Any idea why and how to overcome this?
EDIT: The same thing happens when I don't join (), but read sysout commands (with commons-io):
IOUtils.toString(commandObject.getInputStream()))
source share