So, is this a custom STAF Java service that you've written or a standalone
Java program, or what?

All stdout output from a STAF Java service is redirected to the service's
JVM log.  Do you want your custom STAF Java service to return a STAFResult
(containing a return code and optional result string) so that if a request
is submitted to your STAF Java service from the command line, you get the
STAFResult printed to the console?  If so, then you need to return the data
in the STAFResult (as talked about in the STAF Service Developer's Guide at
http://staf.sourceforge.net/current/stafsdg.html#Header_Writing_Java_Service.

If I didn't answer your question, please provide more information about the
context in which you are running your Java program.

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313




From:   Anna Pereira <annazpere...@gmail.com>
To:     staf-users@lists.sourceforge.net
Date:   09/02/2010 04:31 PM
Subject:        [staf-users] Print result to stdout



Hi,

Forgive me if my question seems really tivial but I am relatively new
to using STAF and Java. I have a Java Class called AllUpgrades that
calls another class called SpUpgrade. There is a bunch of code
executed in SpUpgrade. For example one of the methods in SpUpgrade
executes the following:

String machine = "local";
String command = "/data/STAF/src/scripts/upgrade.sh " + "QUERY" + " "
+ fProduct;
String service = "PROCESS";
String request = "START SHELL COMMAND " +  STAFUtil.wrapData(command)
+ " WAIT RETURNSTDOUT STDERRTOSTDOUT";
STAFResult result = handle.submit2(machine, service, request);

I need to print the result of the above request, so I parse the
request as follows:

STAFMarshallingContext mc = STAFMarshallingContext.unmarshall
(result.result);
Map processCompletionMap = (Map)mc.getRootObject();
String processRC = (String)processCompletionMap.get("rc");
if (!processRC.equals("0"))
                  {
                                 System.out.println("ERROR: STAF " + machine + 
" "
+ service + " " +
request + " RC: " + result.rc + ", Result: " + result.result);
                System.exit(1);

         }

List returnedFileList = (List)processCompletionMap.get("fileList");
Map stdoutMap = (Map)returnedFileList.get(0);
String stdoutRC = (String)stdoutMap.get("rc");
if (!stdoutRC.equals("0"))
                 {

            System.out.println("ERROR retrieving process Stdout data.
RC=" + stdoutRC);
            System.exit(1);

        }

stdoutData = (String)stdoutMap.get("data");
String[] reslines =stdoutData.split(System.getProperty("line.separator"));
for (int i = 0; i < reslines.length; i++)
{
System.out.println("line" + i + ": " + reslines[i]);
return("line" + i + ": " + reslines[i]);
}


But the parsed result is not printed to stdout, it goes to the JVMLog
file. How do I get the above parsed data to be printed on the console?

Thanks
Anna

------------------------------------------------------------------------------

This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users



------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to