webMethods

webMethods

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.  Debugging commands executed by fireCommandExec

    Posted Thu June 26, 2003 02:25 PM

    I’m probably missing something obvious, but I’m trying to figure out a way to debug a shell script that executes F-Secure shell’s sftp2 in batch mode. Using fireCommandExec, is there anyway for me to capture the scripts stderr output?


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


  • 2.  RE: Debugging commands executed by fireCommandExec

    Posted Fri June 27, 2003 12:23 AM

    Not sure if this really answers your question.
    This is how we are invoking scripts thru wM.
    Not really stderr but …

    Process p = Runtime.getRuntime().exec(command);
    p.waitFor();
    returnValue = p.exitValue();
    if (returnValue == 1)
    errorCode = “ER”;
    if (returnValue == 0)
    errorCode = “0”;


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


  • 3.  RE: Debugging commands executed by fireCommandExec

    Posted Fri June 27, 2003 09:24 AM

    No, I am looking for a way to capture the output or errors from the invoked script. As if I was executing the script directly in unix. Maybe it can’t be done or maybe its just not a good practice to invoke scripts through webMethods.

    I know the script kicks off because I see an echoed message in the script’s logfile; however, I need to trap the error messages, not the return code, coming from F-Secure Shell to find out why the sftp portion of the script isn’t working.

    But thanks anyway.


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


  • 4.  RE: Debugging commands executed by fireCommandExec

    Posted Sun June 29, 2003 10:56 AM

    If the thing you are invoking writes to System.out and you need that data, you should be able to do something like the following (make sure you have a finally that sets things back):

    //Redirect System.out
    PrintStream oldOut = System.out;
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    PrintStream newOut = new PrintStream(bos);
    try {
    System.setOut(newOut);
    // do the stuff that writes to System.out
    // …

    // Get the data writen to your print stream
    String output = bos.toString();

    }
    finally {
    System.setOut(oldOut);
    }


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


  • 5.  RE: Debugging commands executed by fireCommandExec



  • 6.  RE: Debugging commands executed by fireCommandExec

    Posted Mon June 30, 2003 09:57 AM

    Have you actually gotten this to work because I can’t. The output variable comes back empty.


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