I am trying to execute a kafka script to retrieve the topic, consumergroups and lag info. I keep getting the error and searching through this and other forums reveals conflicting information. Some say it is not possible to execute a remote script on Unix from windows while others give some advice on what to try to correct this error. I am able to connect and run a simple ping command and able to retrieve the response. Perhaps I am missing a simple overlooked error here.
Here is the code:
try {
jsch.setKnownHosts("C:\\Users\\.ssh\\ssh_host_rsa_key.pub");
Session session = jsch.getSession(uname, host, 22);
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.setPassword(pword);
session.connect();
Process p = Runtime.getRuntime().exec("./usr/kafka/bin/
kafka-consumer-groups.sh --bootstrap-server 192.xxx.xx.xxx:9092
--describe -group OPSII");
InputStream scriptStdout = p.getInputStream();
BufferedReader scriptReader= new BufferedReader(new
InputStreamReader(scriptStdout));
String scriptOutput = scriptReader.readLine();
StringBuilder sb = new StringBuilder();
while ((scriptOutput = scriptReader.readLine())!= null) {
sb.append(scriptOutput + "\n");
}
scriptStdout.close();
The error:
Exception in thread "main" java.io.IOException: Cannot run program
"./usr/kafka/bin/kafka-consumer-groups.sh": CreateProcess
error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
I have confirmed that the script works on the remote unix machine and that the directory is correct. Is it perhaps the format and should it be '//' instead of '/'? What exactly would cause this error? Please this is not a duplicate question as none of the other proposed solutions worked.