Chapter Contents

Previous

Next
SAS/CONNECT User's Guide

Example 3 - Run an Agent

This example runs an agent that is already defined at the DOMAIN server. It then uses the runkey that is returned by the _RUN_AGENT_ method to retrieve the log and output from the agent run.

init:

station_c = 
   loadclass('sashelp.connect.station.class');
station_i = instance(station_c);

collection = 'acollection';
call send(station_i, '_open', collection, rc);

agent_c = loadclass('sashelp.connect.agent');
agent_i = instance(agent_c);

domain = 'tcp//mynode.xyz.com/domsvr';
call send(agent_i, '_setDomainInfo', domain, 
          collection, rc, "", station_i);

   /* name of agent already defined at the    */
   /* domain server                           */
agentname = "reports";
description = 
   'Unscheduled run of thursday night agent';

   /* location of where agent actually        */
   /* runs, which differs from domain name    */
   /* which specifies the DOMAIN server where */
   /* the agent is defined                    */
runloc = 'tcp//mainnode.xyz.com/myserv';

   /* valid userid and password for the system */
   /* on which the agent actually runs (run    */
   /* location)                                */
security = 'userid.password';

runkey=0;
call send(agent_i, '_runAgent', agentname, 
   runkey, rc, description, runloc, security);

if (rc eq 0 ) then do;
   model_c = 
      loadclass('sashelp.connect.runspool.class');
   model_i = instance(model_c);

      /* retrieve agent log and output spool  */
      /* using agent name and runkey that are */
      /* returned by run_agent method         */
   call send(agent_i, '_retrieveAgentRunInfo',
             agentname, runkey, rundt, runcc, 
             rc, model_i, model_i);

   /* now model_i can be used to display log  */
   /* and output from agent run by attaching  */
   /* to text viewer object                   */
end;

return;


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.