Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

First Script using STAX+STAF

nikash
2013-02-13
2013-06-12
  • nikash
    nikash
    2013-02-13

    Hi. I am trying STAF+STAX. Here is what I did:
    1. Installed STAF 3.4.12 on 32 bit Windows 7.
    2. Installed STAX 3.5.4 on same machine - Managed to run default sample1.xml using STAXmon.jar GUI
    3. Managed to copy files using STAF command.

    Now I am trying to create a simple STAX xml - StaxTrying.xml.
    Intention is  1. Ping a machine 2.  Copy File to another machine

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

    <process>
    <location>local</location>
    <command>ping machine1.xyz.com</command>
    </process>

      <stafcmd>
        <location>'machine1.xyz.com'</location>
        <service>'FS'</service>
        <request>'STAF local FS COPY FILE C:\\perlscripts\\answers.txt TODIRECTORY C:\\ TOMACHINE machine1.xyz.com'</request>
      </stafcmd>

    </sequence>
    </stax>

    It fails. Can I get some pointers as to what I am missing?
    Any help is much appreciated!!

    C:\perlscripts>STAF local STAX EXECUTE FILE C:\perlscripts\Staxtrying.xml JOBNAME "SampleJob" CLEARLOGS
    Error submitting request, RC: 4001
    Additional info


    Job ID       : 23
    Error Message: Caught com.ibm.staf.service.stax.STAXXMLParseException:

    Line 19: The content of element type "stax" must match "((function|script|signal
    handler)*,defaultcall?,(function|script|signalhandler)*)".

     
  • Sharon Lucas
    Sharon Lucas
    2013-02-13

    You have an XML parse exception because the <stax> element is only allowed to contain <function>, <script>, <signalhandler> elements and optionally a <defaultcall> element.  However, your <stax> element contains a <sequence> element.  A <sequence> element cannot be contained directly by a <stax> element.  You need to enclose the <sequence> element within a <function> element (giving the function whatever name you want, e.g. Main) and you should to add a <defaultcall> element to specify to call this function by default so that you don't have to specify the function name whenever you submit the job.  For example:

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

    <defaultcall function="Main"/>

    <function name="Main">
      <sequence>

        <process>
          <location>'local'</location>
          <command>'ping machine1.xyz.com'</command>
        </process>

        <stafcmd>
          <location>'machine1.xyz.com''</location>
          <service>'FS'</service>
          <request>'STAF local FS COPY FILE C:\\perlscripts\\answers.txt TODIRECTORY C:\\ TOMACHINE machine1.xyz.com'</request>
        </stafcmd>

      </sequence>
    </function>

    </stax>

    Also, your <process> element element has a couple of syntax errors (missing quotes around local and the ping command) which I corrected in this example.

    Look at section "Sample STAX Jobs" in the STAX User's Guide at http://staf.sourceforge.net/current/STAX/staxug.html#Header_Samples for more examples of complete STAX jobs.

     
  • nikash
    nikash
    2013-02-14

    Thanks! Adding the function tag solved the problem!