Reputation: 1
Hi I am trying to use batch file to clear message from queue. I have list of queues in a file. I am able to read a file in batch program and clear the queue. If the file contains more than one queue to be cleared , I am able to store them in an array , But Passing the array element to MQ command is not working. Please advise. New to batch scripting, so the method
Code :
for /f %%G in (file.txt) do (
set /a count+=1
set fileName[!count!]=%%~G
call set n=!count!
)
rem echo !fileName[%count%]!
for /L %%i in (1,1,%n%) do (
echo !fileName[%%i]!
echo display qlocal(!fileName[%%i]!) | runmqsc %1
)
I have setlocal enabledelayedexpansion enableextensions in the code , and in the above piece echo statement works properly , It is displaying all contents of the array. but it is not getting passed to display qlocal.
New to stackoverflow , if the posting format is not proper apologies.
Upvotes: 0
Views: 234
Reputation: 80033
Use
echo display qlocal(!fileName[%%i]!^) | runmqsc %1
The caret ^
"escapes" the )
so that cmd
sees it as a standard character and does not pair it with the (
in for /L ... do (
which closes the do
block.
Upvotes: 1