I have a shell script that I would like to execute from java.
sudo su - username -c "ssh -t remote_hostname df -k" This shell script works fine when you ran from the command prompt. However when I used process builder it will not return anything. If I do the following: sudo su - username -c ssh -t remote_hostname;df -k
then the command is running on my local machine not on the remote machine.
Appreciated any feedback.
java code
Process p; ExecutorService es = null; try { p = Runtime.getRuntime().exec(test1.sh); StreamGobbler sg = new StreamGobbler(p.getInputStream(), System.out::println()); es = Executors.newSingleThreadExecutor(); es.submt(sg); int exitCode = p.waitfor(); assert exitCode == 0; es.shutdown(); } catch (....) { }