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?
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);
returnValue = p.exitValue();
if (returnValue == 1)
errorCode = “ER”;
if (returnValue == 0)
errorCode = “0”;
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.
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):
PrintStream oldOut = System.out;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream newOut = new PrintStream(bos);
// do the stuff that writes to System.out
// Get the data writen to your print stream
String output = bos.toString();
This looks like an easier and safer way:
Have you actually gotten this to work because I can’t. The output variable comes back empty.