midrange.com code scratchpad
Name:
Capturing QSH0005 error messages.
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
02/24/2020 03:02:08 pm
IP:
Logged
Description:
Using QIBM_QSH_CMD_ESCAPE_MESSAGE to capture QSH errors.
Code:
  1. /kevin/returnerror.sh is:
  2.  
  3. #!/bin/bash 
  4. return 7    
  5.  
  6. I made it executable by chmod +x /kevin/returnerror.sh
  7.  
  8. RPGLE program.
  9.  
  10. **Free
  11.  
  12.     Dcl-Ds Pgmsts psds;
  13.       Pgm *Proc;
  14.       ErrId Char(7) Pos(40);
  15.       ErrMsg Char(80) Pos(91);
  16.     End-Ds;
  17.  
  18.     Dcl-Pr QCmdExc Extpgm;  // Execute a command
  19.       *N Char(1500) Options(*VarSize) Const ;
  20.       *N Packed(15:5) Const ;
  21.     End-Pr ;
  22.  
  23.     Dcl-S Command VarChar(1500);
  24.     Dcl-S FiftyTwo Char(52);
  25.  
  26.     Command = 'ADDENVVAR ENVVAR(QIBM_QSH_CMD_ESCAPE_MSG) VALUE(Y) REPLACE(*YES)';
  27.     QCmdExc(Command:%Len(Command));
  28.  
  29.     Command = 'STRQSH CMD(''/kevin/returnerror.sh'')';
  30.     Monitor;
  31.       QCmdExc(Command:%Len(Command));
  32.     On-Error;
  33.       FiftyTwo = Errmsg;
  34.       Dsply FiftyTwo;
  35.     EndMon;
  36.  
  37.     *Inlr = *On;
  38.     Return;  
  39.  
  40.  
© 2004-2019 by midrange.com generated in 0.012s valid xhtml & css