| midrange.com code scratchpad | 
				
					| 
							
								| Name:Capturing QSH0005 error messages. | Scriptlanguage:Plain Text | Tabwidth:4 | Date:02/24/2020 09:02:08 pm | IP:Logged |  | 
				
					| Description:Using QIBM_QSH_CMD_ESCAPE_MESSAGE to capture QSH errors. | 
				
					| Code: 
							
								
								
								| 
    /kevin/returnerror.sh is:
 #!/bin/bash 
return 7    
 I made it executable by chmod +x /kevin/returnerror.sh
 RPGLE program.
 **Free
     Dcl-Ds Pgmsts psds;
      Pgm *Proc;
      ErrId Char(7) Pos(40);
      ErrMsg Char(80) Pos(91);
    End-Ds;
     Dcl-Pr QCmdExc Extpgm;  // Execute a command
      *N Char(1500) Options(*VarSize) Const ;
      *N Packed(15:5) Const ;
    End-Pr ;
     Dcl-S Command VarChar(1500);
    Dcl-S FiftyTwo Char(52);
     Command = 'ADDENVVAR ENVVAR(QIBM_QSH_CMD_ESCAPE_MSG) VALUE(Y) REPLACE(*YES)';
    QCmdExc(Command:%Len(Command));
     Command = 'STRQSH CMD(''/kevin/returnerror.sh'')';
    Monitor;
      QCmdExc(Command:%Len(Command));
    On-Error;
      FiftyTwo = Errmsg;
      Dsply FiftyTwo;
    EndMon;
     *Inlr = *On;
    Return;  
   |  | 
				
					|  |