2.1 STAF Java ???????

????2???????STAF Java?????????

????2??STAF Java???????

    STAFHandle handle = null;
    try {
      handle = new STAFHandle("Java_Sample_Test");
    } catch (STAFException e) {
      System.exit(1);
    }

    STAFResult result = handle.submit2("Linux1"?? "process"??
      "start command ls parms -l wait stdout /root/lsjava.log");
    if (result.Ok != result.rc) {
      System.out.println("Error starting the process ls?? RC:  " + result.rc);
    }

    result = handle.submit2("Linux1"?? "fs"?? "copy FILE /root/lsjava.log
      TODIRECTORY C:/STAF TOMACHINE windows' % machineName");
    if (result.Ok != result.rc) {
      System.out.println("Error coping file?? RC: " + result.rc);
    }

?????STAF??????????????????STAFHandle?????е?STAF???????????????????????У?????????????????ó?????????handle.submit2()??????????STAF??????????????????????

2.2 STAX??????

STAX???????????STAF???????????????????STAX?????????STAF????????????????????????????????STAX?????????

????3??STAX???SampleScript.xml???

    1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    2 <!DOCTYPE stax SYSTEM "stax.dtd">       
    3 <!-- sample1.xml - Sample of a job definition file for STAX
    4 Job Description:
    5   This job executes some STAF commands and sends messages to the STAX Job Monitor.
    6 -->
    7  <stax>
    8   <script> LinuxMachine = ['Linux1'?? 'Linux2'] </script>
     
    9   <defaultcall function="ListDirectory">
    10   </defaultcall>
     
    11   <function name="ListDirectory">
      
    12     <paralleliterate var = "machineName" in="LinuxMachine">
    13       <testcase name = "'listDirectory'">
    14         <sequence>
            
    15           <stafcmd>
    16             <location>'%s' % machineName</location>
    17             <service>'process'</service>
    18             <request>'start command "ls" parms "-l" wait stdout /root/ls.log'</request>
    19           </stafcmd>
            
    20           <if expr="RC == 0">
    21             <sequence>
    22               <tcstatus result="'pass'"/>
    23               <log message="1">'List directory successfully on %s' % machineName</log>
    24             </sequence>
    25             <else>
    26               <sequence>
    27                 <tcstatus result="'fail'"/>
    28                 <log message="1">'Error in listing directory on %s' % machineName</log>
    29               </sequence>
    30             </else>
    31          </if>

    32           <stafcmd>
    33             <location>'%s' % machineName</location>
    34             <service>'fs'</service>
    35             <request>'copy FILE /root/ls.log TOFILE ls%s.log TODIRECTORY C:/STAF
                        TOMACHINE windows' % machineName</request>
    36           </stafcmd>

    37         </sequence>
    38       </testcase>
    39     </paralleliterate>       
    40   </function>
    41 </stax>

?????????????Linux???????ls?????????????????????????????????ж??????????????????????????STAF?????С??????????????????????к??

STAX???????????е?XML???????????????????????XML????????????????б????XML??????stax.dtd????????????????е?STAX???????????????????С?