Hello Michael,

On Thursday 12 January 2006 22:08, Michael MacIsaac wrote:
> Is there a way to get vmcp to return the CP return code rather than 1?
>
> hcp behaves as I'd expect:
> # hcp q linux04
> HCPCQU045E LINUX04 not logged on
> # echo $?
> 45
>
> But vmcp seems to return only 0 or 1:
>
> # vmcp q linux04
> HCPCQU045E LINUX04 not logged on
> Error: non-zero CP response for command 'Q LINUX04': #45
> # echo $?
> 1

There was a discussion some times ago and it became obvious that you simply 
cannot map all CP codes to Linux return codes. Linux return codes can be 0-255. 
If you look into "System Messages and Codes -- CP" (GC24-6119-00) Chapter 3 you 
will see that HCP codes go up to 9967. SO it is simply no possible to map 
0-9967 into 0-255 without some information being lost. We had to find a way to 
return all possible cp response codes and still have a list of well defined 
return codes. 


The current version (1.5.1) of vmcp returns the following return codes:
0      No problem in vmcp or CP.
1      CP returned a non-zero response code.
2      The specified buffer was not large enough to hold CP's response. The
       command was executed,  nevertheless, and the response was truncated.
        You can use the --buffer option to increase the response buffer.
3      Linux reported an error to vmcp. See the error message for details.
4      The options passed to vmcp were erroneous. See the error messages.


> So do I have to parse the stdout (which gets ugly) to get the rc?  Thanks.

Yes and no. While the output goes to stdout, the vmcp error message you have 
seen goes to stderr. You can check for return code 1 and parse only in that 
case the output of stderr. There is alway a "#" in front if the number, which 
might help you parsing. 

If you really dont like it that way, you can also use cpint(Both tools can 
coexist), which has the limitation mentioned above. There is no "right" 
solution for this mapping. Each method has its downsides. 

If changing code is an option for you, you can also change the user space part 
of vmcp. Simply replace the line "return VMCP_CP;" with "return response_code;" 
at the end of vmcp.c and recompile it. 

cheers

Christian

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to