Author |
Message
|
ruimadaleno |
Posted: Mon Mar 23, 2015 1:42 am Post subject: running several mqsistopmsgflow in a single script file |
|
|
Master
Joined: 08 May 2014 Posts: 274
|
Hi all,
i've built a script to stop several message flows in several execution groups.
The script is run from command console (so the profile is imported) but only the first command is run and the script exits ...
script:
Code: |
@echo off
rem --------------------------------------------------------
rem descricao: script para stop de message flows no execution group default
rem
rem --------------------------------------------------------
REM
SET BROKER_NAME=BRKDVESB01A
SET EXECUTION_GROUP=default
SET DEPLOY_WAIT=600
echo ..................................
echo script iniciado as %TIME% de %DATE%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k emailws -m gen.EmailWS -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k smsws -m gen.SmsWS -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k FileNetWS_V2 -m FileNetWS -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k SGMBEntities -m gen.Entities -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k SGMBPolicies -m gen.Policies -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k SGMBPoliciesChanges -m gen.PoliciesChanges -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k SGMBReceipts -m gen.Receipts -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k EurotaxWS -m gen.EurotaxWS -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k RotasAutenticacao -m gen.RotasAutenticacao -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k RotasGestao -m gen.RotasGestao -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k RotasInfo -m RotasInfo -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k AcoreanaCreateProcessWFProducao -m acoreana.CreateProcessWFProducao -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k SIGACreateProcess -m acoreana.siga.esb.ps.SIGACreateProcessProxyService -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k ScoringAuto -m gen.ScoringAuto -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -contact admin -m gen.contact admin -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k SibsPRT -w %DEPLOY_WAIT%
mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k BPMGestRecBroker -w %DEPLOY_WAIT%
echo script Finished at %TIME% at %DATE% com nivel de erro: %ERRORLEVEL%
echo ..................................
|
script output:
Code: |
C:\BarFiles\reorg>script_stop_message_flow_eg_default.bat
..................................
script iniciado as 9:41:18,72 de 23-03-2015
BIP1028I: Stopping message flow 'gen.EmailWS' on execution group 'default' (Appl
ication 'emailws', Library '')...
BIP1031I: Message flow 'gen.EmailWS' on execution group 'default' is reported as
stopped. (Application 'emailws', Library '')
BIP8071I: Successful command completion.
C:\BarFiles\reorg>
|
what is wrong with this script ?  _________________ Best regards
Rui Madaleno |
|
Back to top |
|
 |
ruimadaleno |
Posted: Mon Mar 23, 2015 2:10 am Post subject: |
|
|
Master
Joined: 08 May 2014 Posts: 274
|
i've manage to find a solution
solution: add an "cmd /c " before each msqistopmsgflow command
Code: |
@echo off
rem --------------------------------------------------------
SET BROKER_NAME=BRKDVESB01A
SET EXECUTION_GROUP=default
SET DEPLOY_WAIT=600
echo.
echo MQSI %MQSI_VERSION%
echo %MQSI_FILEPATH%
echo.
echo ..................................
echo script iniciado as %TIME% de %DATE%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k emailws -m gen.EmailWS -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k smsws -m gen.SmsWS -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k FileNetWS_V2 -m gen.FileNetWS -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k SGMBEntities -m gen.Entities -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k SGMBPolicies -m gen.Policies -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k SGMBPoliciesChanges -m gen.PoliciesChanges -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k SGMBReceipts -m gen.Receipts -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k EurotaxWS -m gen.EurotaxWS -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k RotasAutenticacao -m gen.RotasAutenticacao -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k RotasGestao -m gen.RotasGestao -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k RotasInfo -m gen.RotasInfo -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k AcoreanaCreateProcessWFProducao -m acoreana.CreateProcessWFProducao -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k SIGACreateProcess -m acoreana.siga.esb.ps.SIGACreateProcessProxyService -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k ScoringAuto -m gen.ScoringAuto -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k contact admin -m gen.contact admin -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k SibsPRT -w %DEPLOY_WAIT%
cmd /c mqsistopmsgflow %BROKER_NAME% -e %EXECUTION_GROUP% -k BPMGestRecBroker -w %DEPLOY_WAIT%
echo script Finished at %TIME% at %DATE% com nivel de erro: %ERRORLEVEL%
echo ..................................
|
Now another problem
if one of the mqsistopmsflowcommand generates an error, how does the script returns this error ?
In the end of the script i use "echo %ERRORLEVEL%" to ouput the error level, but this is the error from the last command issued. what is the best way to store the errors happening in the middle of the script ? _________________ Best regards
Rui Madaleno |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Mar 23, 2015 4:25 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
This is why your solution with cmd /c is a little bit over the top.
Replace your cmd /c with call. That should do it. At the same time %errorlevel% will be set to the exit value of the batch called.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
smdavies99 |
Posted: Mon Mar 23, 2015 6:05 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
There are a number of mqsi* commands that 'work' like this.
mqsicreateexecutiongroup is another.
I solve this by writing the mqsicommand to a temporary .bat file and calling it.
I also wrap the command in an setlocal/endlocal structure.
I find this behaviour rather annoying. It would be nice if IBM resolved it... _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Mar 23, 2015 7:13 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
smdavies99 wrote: |
There are a number of mqsi* commands that 'work' like this.
mqsicreateexecutiongroup is another.
I solve this by writing the mqsicommand to a temporary .bat file and calling it.
I also wrap the command in an setlocal/endlocal structure.
I find this behaviour rather annoying. It would be nice if IBM resolved it... |
That's going a little bit overboard too.
Instead of writing mqsicreateexecutiongroup into your batch file, just write call mqsicreateexecutiongroup. No need to create another layer with the temp file...
You may have a point with the setlocal / endlocal commands however my understanding is that the mere execution of some of the mqsi*.exe command may also change your environment (look at mqsisetmqenv.bat and mqsifindmqpath.exe)  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|