IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Java Service to run a cmd line

    Posted Fri July 12, 2002 07:58 AM

    Does anybody has a Java service doing a cmd Line (Like ls or any kind of cmd line)


    #Integration-Server-and-ESB
    #webMethods
    #webMethods-General


  • 2.  RE: Java Service to run a cmd line

    Posted Sat July 13, 2002 09:36 AM

    This is the example in 4.6 WmSamples package. Remember a service like this can cause opportunity for misuse, so keep an ACL on it and if possible hardcode a single specific command line.

    public static final void fireCommandExec (IData pipeline)
    throws ServiceException
    {
    // — <<B2B-START(fireCommandExec)>> —
    // @sigtype java 3.5
    // [i] field:0:required fullCommand
    // [o] field:0:required successFlag
    //define input variables
    IDataCursor idcPipeline = pipeline.getCursor();
    String strFileContent = null;

    //Output Variables
    String successFlag = “false”;
    String fullCommand ;

    // Check to see if the fullCommand object is in the pipeline
    if (idcPipeline.first(“fullCommand”))
    {
    //get the fullCommand stream out of the pipeline
    fullCommand = (String) idcPipeline.getValue();
    }
    //if it is not in the pipeline, then handle the error
    else {
    util.Log.log(“Error executing sample.io.commandLineExec.fileCommandExec: Required parameter ‘fullCommand’ missing.”, “sample.commandLineExec”);
    return;
    }

    //Run the command
    String execFile = (String) idcPipeline.getValue() ;

    //Execute the command. Handle the exception if it fails.
    try {
    Process child = Runtime.getRuntime().exec(execFile);
    successFlag=“true”;
    }
    catch (IOException e) {
    //Write the error to server.log
    util.Log.log("Error executing sample.io.commandLineExec.fileCommandExec: " + e.toString(), “sample.commandLineExec”);
    successFlag=“false”;
    }

    //insert the successFlag into the pipeline
    idcPipeline.insertAfter(“successFlag”, successFlag);

    //Always destroy cursors that you created
    idcPipeline.destroy();
    // — <> —
    }


    #webMethods-General
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: Java Service to run a cmd line

    Posted Mon August 19, 2002 02:21 PM

    Hi,

    I tried running cmd but it doesn’t pop up or proceed any further commands that I would do on a cmd window. Any Views ??


    #webMethods
    #Integration-Server-and-ESB
    #webMethods-General