ibm mq - Read mq queue errors in .bat file -


i using amqsput write message queue in batch file.

call "c:\folderdir\code\mqfile\amqsput" queue qmgr < file 

the code works fine. want capture errors , echo appropriate response message.

ex - if queue full, mq return error code , message. want capture message , code , print on screen.

errorlevel doesnt capture mq error codes.

capture output using for /f loop.

@echo off /f "delims=" %%a in ('call "c:\folderdir\code\mqfile\amqsput" queue qmgr ^< file 2^>^&1') echo(%%a pause 

2>&1 redirecting stderr stdout , for /f loop capturing stdout.

example / proof of concept

test.bat

@echo off /f "delims=" %%a in ('call test2.bat ^< test.txt 2^>^&1') echo(test = %%a pause exit /b 0 

test2.bat

@echo off set /p "test=" echo(%test% echo error 1>&2 exit /b 0 

test.txt

hello 

output

c:\users\user\desktop>test.bat test = hello test = error press key continue . . . 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -