SSH/cmd-line call - Forum - Technology Partner - Progress Community

SSH/cmd-line call

  • Hi all,

    Is it possible to make a command-line call from the ESB (7.0.2) and retrieve the results?  If so, how?


    Herbie Wilson

  • You can do this with a custom service where you use the Java Runtime object.   Something like:


    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) {

                    int exitVal = pr.waitFor();
                    System.out.println("Exited with error code "+exitVal);

                } catch(Exception e) {

    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.