If you want a STAX job's result to be set to a message then you need to 
return that message from the STAX job's main function using the <return> 
element.
For example:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "stax.dtd">

<stax>

  <defaultcall function="test"/>

  <function name="test">
    <sequence>

      <script>command = 'ls /'</script>

      <!-- Run a command (e.g. "ls /")and return its stdout/stderr -->
      <process>
        <location>'local'</location>
        <command mode="'shell'">command</command>
        <stderr mode="'stdout'"/>
        <returnstdout/>
      </process>

      <if expr="RC == 0">
        <script>lsOutput = 'Output from "%s" command:\n%s' % (command, 
STAXResult[0][1])</script>
        <else>
          <script>
            lsOutput = '"%s" failed with RC=%s, STAFResult=%s, 
STAXResult=%s' % \
                       (command, RC, STAFResult, STAXResult)
          </script>
        </else>
      </if>

      <message log="1">lsOutput</message>

      <!-- Get the current date-time -->
      <script>
        from time import localtime, strftime
        currentTime = strftime("%a, %d %b %Y %H:%M:%S", localtime())
      </script>

      <message log="1">'Current date-time: %s' % currentTime</message>

      <!-- Create a result containing "Hello world", the current 
date-time, and output from "ls /" command --> 
      <script>result = 'Hello world @ %s.\n%s' % (currentTime, 
lsOutput)</script>

      <!-- Log the result in the STAX Job User Log and send to the STAX 
Monitor messages -->
      <message log="1">result</message>

      <!-- Return the result -->
      <return>result</return>

    </sequence>
  </function>

</stax>

You can submit a STAX EXECUTE request to run this STAX job and wait for it 
to complete and return its job result as follows:

# STAF local STAX EXECUTE FILE C:/stax/returnJobResult.xml WAIT 
RETURNRESULT DETAILS
Response
--------
{
  Job ID         : 12
  Start Date-Time: 20130725-08:02:14
  End Date-Time  : 20130725-08:02:15
  Status         : Normal
  Result         : Hello world @ Thu, 25 Jul 2013 08:02:15.
Output from "ls /" command:
Cygwin.bat
Cygwin.ico
Thumbs.db
bin
cygdrive
dev
etc
home
lib
proc
tmp
usr
var

  Job Log Errors : []
  Testcase Totals: {
    Tests : 0
    Passes: 0
    Fails : 0
  }
  Testcases      : []
}

For more information on the <return> element, see section "return: Return 
from a Function" in the STAX User's Guide at 
http://staf.sourceforge.net/current/STAX/staxug.html#Header_Return

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




From:   babuni mishra <bab...@outlook.com>
To:     "staf-users@lists.sourceforge.net" 
<staf-users@lists.sourceforge.net>, 
Date:   07/25/2013 06:46 AM
Subject:        [staf-users] simple stax script



Hi ,
I am a newbie to STAX, wants to use in my automated solution in Linux Env.
Can any one share me a sample stax script which will return me 
1) hello world message & current date & output of 'ls' (unix command) 

both in STDOUT & in a file.

I have followed couple of blogs, executed sample stax script aswell, but 
not able to get the result ,  it always comes as 
 Result         : None


Thanks,
Bab
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to