Invoke XMLSERVICE from PASE shell

Issue #5 resolved
Aaron Bartell created an issue

I am in a situation where it would be handy to invoke XMLSERVICE from a shell script. Being able to do so will allow me to eliminate the need to install Ruby/Node.js/Python iToolKits.

Here's what I have so far:

$ alias db2='function _db2(){ echo "Running $1"; system -i "call QSYS/QZDFMDB2 parm('\''$1'\'')"; };_db2'
$ db2 "CALL QXMLSERV.iPLUG4K('''', ''*immed'', ''<?xml version="1.0"?>'', ?)"
Running CALL QXMLSERV.iPLUG4K('''', ''*immed'', ''<?xml version=1.0?>'', ?)

 **** CLI ERROR *****
         SQLSTATE: 07001
NATIVE ERROR CODE: -313
Number of host variables not valid.

This error makes sense, but I am not finding a way to specify a host variable from a shell to obtain the output of the last parameter. I believe this might be remedied by wrapping iPLUG4K with another RPG program that writes to standard out, but I wanted to first check if anyone has gotten it to work without that.

Comments (2)

  1. Former user Account Deleted

    Wrong stored proc iPLUG4K has I/O last parm (forbidden). Switch to iPLUGR4K for a natural result set (below).

    FYI -- Although on a personal note, languages and toolkits are for normal people (you shell hacker).

    bash-4.3$ alias db2='function _db2(){ echo "Running $1"; system -i "call QSYS/QZDFMDB2 parm('\''$1'\'')"; };_db2'
    bash-4.3$ db2 "CALL XMLSERVICE.iPLUGR4K(''*na'', ''*here'', ''<?xml version="1.0"?><script><sh>ls</sh></script>'')"
    Running CALL XMLSERVICE.iPLUGR4K(''*na'', ''*here'', ''<?xml version=1.0?><script><sh>ls</sh></script>'')
    
     **** CLI ERROR *****
             SQLSTATE: 0100C
    NATIVE ERROR CODE: 466
    1 result sets are available from procedure IPLUGR4K in XMLSERVICE. 
    
    OUT151                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    <?xml version=1.0?><script><sh>
    README.md
    READNOTES.txt
    contributors.txt
    iayecmd.rpgle
    iayedata.rpgle
    iayeds.rpgle
    iayejunk.rpgle
    iayelic.rpgle
    iayelic_h.rpgle
    iayeos.rpgle
    iayeos_h.rpgle
    iayeparm.rpgle
    iayeperf.rpgle
    iayeperf_h.rpgle
    iayepgm.rpgle
    iayerun.rpgle
    iayerun_h.rpgle
    iayesh.rpgle
    iayesql.rpgle
    iayesrv.rpgle
    iayesrv_h.rpgle
    iayexml.rpgle
    iayexml_h.rpgle
    make.sh
    testbig.rpgle
    testloop.rpgle
    testpgm.rpgle
    testpgm2.rpgle
    </sh>
    </script>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    
      1 RECORD(S) SELECTED.
    
    bash-4.3$ 
    
  2. Log in to comment