Yes, a PROCESS START WAIT request that starts the command successfully 
returns the return code of the command being run in the result.  For 
example, if myscript.py returns 99:

# Contents of /tests/myscript.py
import sys
sys.exit(99)

STAF local PROCESS START SHELL COMMAND "/tests/myscript.py" WAIT
Response
--------
{
  Return Code: 99
  Key        : <None>
  Files      : []
}

You can also return output that the command writes to stdout/stderr.  For 
example:

# Contents of /tests/myscript.py
import sys
print "Get an error"
sys.exit(99)


STAF local PROCESS START SHELL COMMAND "/tests/myscript.py" WAIT 
RETURNSTDOUT STDERRTOSTDOUT
Response
--------
{
  Return Code: 99
  Key        : <None>
  Files      : [
    {
      Return Code: 0
      Data       : Got an error

    }
  ]
}

This is documented in the STAF User's Guide in section "8.12 Process 
Service, sub-section "8.12.2 START", sub-section "Results" at 
http://staf.sourceforge.net/current/STAFUG.htm#HDRPROCSRV.  It says:

If the WAIT option is specified and the submit call does not timeout, the 
result buffer will contain a marshalled 
<Map:STAF/Service/Process/CompletionInfo> which represents the completion 
information for the process, including the return code from the process, 
the KEY (if one was specified with the NOTIFY ONEND option), as well as 
any files specified by RETURNSTDOUT, RETURNSTDERR, and/or RETURNFILE. 
The maps are defined as follows: 
Table 61. Definition of map class STAF/Service/Process/CompletionInfo
Description: This map class represents completion information for a 
process. 
Key Name 
Display Name 
Type 
Format / Value 
rc 
Return Code 
<String> 

key 
Key 
<String> | <None> 

fileList 
Files 
<List> of <Map:STAF/Service/Process/ReturnFileInfo> 

Notes: The "Files" value will contain a list of information about the 
files requested to be returned, or an empty list if no files were 
requested to be returned. Files will be returned in the order of standard 
output, then standard error, then any files specified with the RETURNFILE 
option. 

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




From:   Andrew More <andrewmore2...@hotmail.com>
To:     STAF Users Mailing list <staf-users@lists.sourceforge.net>
Date:   08/03/2011 10:11 PM
Subject:        Re: [staf-users] How to get process exit / return code 
started with PROCESS service



missed subject earlier :)

From: andrewmore2...@hotmail.com
To: staf-users@lists.sourceforge.net
Subject: 
Date: Thu, 4 Aug 2011 07:04:18 +0400

Hi,

Is there a way to get the exit / return code of a process (which is some 
script) started with PROCESS service?
For example:

staf local process start shell command "myScript.py" wait 


-- Andrew
------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to