If from machine host1, you submit a QUEUE GET request to the hostname of a
remote machine, e.g. host2, you'll get an RC 25 error like the following:

C:\>STAF host2 QUEUE GET WAIT 5000
Error submitting request, RC: 25
Additional info
---------------
QUEUE service's GET request is only valid if submitted to the local machine
Local machine     : host2.company.com
Requesting machine: host1.company.com

This is because STAF only allows you to get messages off your own STAF
handle's queue for security reasons.  That is, only the STAF handle of the
process to which the message was sent can submit a GET request to the QUEUE
service.  This means that you must specify "local" for the service request
and submit the QUEUE GET request using the specified handle.  This is
documented in section "8.13.3 GET/PEEK" in the STAF User's Guide at
http://staf.sourceforge.net/current/STAFUG.htm#HDRQUEUESRV in the Security
sub-section that says:  "These commands are only valid with respect to the
submitting process' queue and if submitted to the local machine. ".

So, this means that you need to submit a local QUEUE GET request on the
machine where the STAF handle exists.  So, if the message was sent to a
handle on machine host2, then you would need to submit a QUEUE GET request
on machine host2 specifying "local" for the machine, e.g.

STAF local QUEUE GET WAIT 5000

If you submit this request from the STAF command line, then you would first
need to create a static handle and set STAF_STATIC_HANDLE to the handle
number of the static handle you created because, otherwise, the STAF
executable will automatically create a new STAF handle to use to submit the
QUEUE GET request, and then automatically delete the handle (since the
handle no longer exists, you obviously cannot get any message's off the
handle's queue).

Rather than using the STAF command line executable to submit the QUEUE GET
request, you can submit it via a program (e.g. Java, C++, Perl, Python,
Tcl) using the STAF APIs provided for each language to first register with
STAF specifying a handle name such as MyProcess (which creates a STAF
handle with this name).  Then you can send messages to this STAF handle
(via its handle name or number) from the same or remote machines (e.g. by
specifying this handle via the HANDLE or NAME option on a PROCESS START
NOTIFY ONEND request), and then submit a "GET" request to the "QUEUE"
service on the local machine via the program to get messages off its
handle's queue.

When you start a process asynchronously via a PROCESS START request and use
the NOTIFY ONEND option to send a notification when this process ends, by
default, the STAF/Process/End notification message is sent to the handle of
the process submitting the PROCESS START request on the machine submitting
the PROCESS START request.  If you want to have the STAF/Process/End
notification message sent to another machine/handle, then you need to
specify the following options as well:

- MACHINE specifies the machine to which the notification should be sent.
The default is the machine submitting the request.

and one of the following options:

- HANDLE specifies the handle to which the notification should be sent. The
default is the handle of the process submitting the request.
or
- NAME specifies the registered name of the process(es) to which the
notification should be sent.

Note, these options are documented in the STAF User's Guide in section
"8.12.2 START" at
http://staf.sourceforge.net/current/STAFUG.htm#HDRPROCSRV.  And are shown
in the help for the PROCESS service as follows:

C:\>STAF local PROCESS HELP
Response
--------
*** PROCESS Service Help ***

START [SHELL [<Shell>]] COMMAND <Command> [PARMS <Parms>] [WORKDIR
<Directory>]
      [VAR <Variable>=<Value>]... [ENV <Variable>=<Value>]...
[USEPROCESSVARS]
      [WORKLOAD <Name>] [TITLE <Title>] [WAIT [<Number>[s|m|h|d|w]] |
ASYNC]
      [STOPUSING <Method>] [STATICHANDLENAME <Name>]
      [NEWCONSOLE | SAMECONSOLE] [FOCUS <Background | Foreground |
Minimized>]
      [USERNAME <User Name> [PASSWORD <Password>]]
      [DISABLEDAUTHISERROR | IGNOREDISABLEDAUTH]
      [STDIN <File>] [STDOUT <File> | STDOUTAPPEND <File>]
      [STDERR <File> | STDERRAPPEND <File> | STDERRTOSTDOUT]
      [RETURNSTDOUT] [RETURNSTDERR] [RETURNFILE <File>]...
      [NOTIFY ONEND [HANDLE <Handle> | NAME <Name>]
      [MACHINE <Machine>] [PRIORITY <Priority>] [KEY <Key>]]

So, for example, if on machine host1 you want to start a process
asynchronously on machine host2 and a STAF handle named MyProcess already
exists on machine host 2, you could submit a PROCESS START request from
machine host1 specifying to send a process completion message to the queue
associated with handle(s) named MyProcess that exist on machine host2..

So, on host2, create a STAF handle, e.g. named MyProcess, either via a
program or using the STAF executable via the command line.  For example:

C:\>STAF local HANDLE CREATE HANDLE NAME MyProcess
Response
--------
11

On host1, submit the PROCESS START request specifying to send a
STAF/Process/End notification message to any handles named MyProcess on
machine host2:

C:\>STAF host2 PROCESS START SHELL COMMAND hostname RETURNSTDOUT
RETURNSTDERR NOTIFY ONEND MACHINE host2 NAME MyProcess
Response
--------

On machine host2, via a program that registered for STAF as a handle named
MyProcess or via the command line using the STAF executable when using a
static handle named MyProcess, you can submit the following request to wait
for the STAF/Process/End message.  For example:

C:\>set STAF_STATIC_HANDLE=11

C:\>STAF local QUEUE GET WAIT 5000
Response
--------
{
  handle             : 1
  handleName         : STAF_Process
  machine            : ssl://host2.company....@6550
  message            : {
    endTimestamp: 20100913-13:48:37
    fileList    : [
      {
        data: host2

        rc  : 0
      }
      {
        data:
        rc  : 0
      }
    ]
    handle      : 14
    key         :
    rc          : 0
  }
  priority           : 5
  staf-map-class-name: STAF/Service/Queue/Entry
  timestamp          : 20100913-13:48:38
  type               : STAF/Process/End
  user               : none://anonymous
}

I hope this helps explains how to send a process completion notification
message to a STAF handle on any machine and how to get this message off the
STAF handle's queue.

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313




From:   Arvind Chandra <arv...@yahoo.com>
To:     staf-users@lists.sourceforge.net
Date:   09/13/2010 01:04 PM
Subject:        [staf-users] Getting response from process running on different
            hosts



Hi,
      Is there a way to get the response from process running on different
host.
I would like not to use the STAF_STATIC_HANDLE

Example can be something like

host1 - local machine
host2 - remote machine


staf host2 process start shell command hostname returnstdout returnstderr
notify
onend

And I can run the command

staf host2 queue get wait 5000


But that is giving me error and it can not get notifications on remote
machines.


Thanks
Arvind




------------------------------------------------------------------------------

Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to