Command

(click to open)

Quick Page Table of Contents

Scanning…

Ruby Toolkit Don: Invoking an IBMi Command …

XMLSERVICERubyDonWork

THIS PAGE IS COMPLETELY OUT OF DATE (WRONG)

do not use

The easiest way to test xmlservice commands is to use the Rails console. Otherwise you will need to create a controller to run your commands, a view to display the output and then modify /config/routes with the URL. The following shows how to display the system value QTIME:

/> cd /your_rails_app
/YOUR_RAILS_APP> rails console
irb(main):001:0> require ‘xmlservice’
irb(main):001:0> ActiveXMLService::Base.establish_connection connection: ‘ActiveRecord’
irb(main):001:0> cmd = XMLService::I_SH.new(“system -i ‘WRKSYSVAL SYSVAL(QTIME) OUTPUT(*PRINT)’”)
irb(main):001:0> cmd.xmlservice
irb(main):001:0> puts cmd.out_xml

The put string method output the following to my console:

<?xml version='1.0'?>
<myscript>
<sh error='fast'>
                                                   System Values                                                        Page     1
5770SS1 V7R1M0  100423                                                                            RORSERV2  12/02/13  17:26:44 UTC
                Current                         Shipped
 Name           value                           value                           Description
 QTIME          17:26:44                        ' '                             Time of day
     Note:  > means current value is different from the shipped value
                                         * * * * *   E N D  O F  L I S T I N G   * * * * *
</sh>
</myscript>

All XMLService invocations set the out_xml attribute with response information so note that you can use any one of many XML parsers that are available to pull out specific elements from the XML.

Retrieve command parameter values

TODO flesh out after updating xmlservice on RORSRVR2

cmd = XMLService::I_CMD.new("RTVJOBA USRLIBL(?) SYSLIBL(?)")
    # call IBM i
    cmd.xmlservice
    # output
    puts "USRLIBL #{cmd.xml_USRLIBL}"
    puts "SYSLIBL #{cmd.xml_SYSLIBL}"