Hi all,
Is it possible to make a command-line call from the ESB (7.0.2) and retrieve the results? If so, how?
Thanks,
Herbie Wilson
You can do this with a custom service where you use the Java Runtime object. Something like:
import java.io.*;
public class Main {
public static void main(String args[]) {
try {
java.lang.Runtime rt = java.lang.Runtime.getRuntime();
java.lang.Process pr = rt.exec("cmd /c dir");
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line=null;
while((line=input.readLine()) != null) {
System.out.println(line);
}
int exitVal = pr.waitFor();
System.out.println("Exited with error code "+exitVal);
} catch(Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}
}
}
NOTE: You have to be careful about doing things like this, as they can open up a wide security hole in your environment if you let an ESB Service run random commands.