1.

Solve : Newbie help: bat calling .bat file only executes 1st file?

Answer»

This should be easy...

I'm trying to execute 28 .bat files, located on c:\dir\subdir\
[1.BAT, 2.BAT, 3.BAT... 28.BAT]

the 'CONTROL.bat' file lives on e:\myholddir


CONTROL.BAT
C:
CD\DIR\SUBDIR
1.BAT
REM --- 1
2.BAT
REM --- 2
3.BAT
REM --- 3
...
...
28.BAT
REM --- EOF ---


(I execute (from command prompt, win200),
the 1.bat executes successfuly, but ends.

2.bat and the rem --- 1 never is called.

should I add 'CALL' in front of the *.bat files?

fwiw, the 1.bat is calling a 3rd party tool (data integrator).

any ideas?

thanks in advance!!! Do any of the 1.BAT, 2.BAT etc have an EXIT in them?

this will cause the whole thing to stop running.Quote

bat calling .bat file only executes 1st file

The problem is you're not calling the batch files but EXECUTING them. There is a subtle difference. When you call a batch file a mechanism is setup to return to the calling file. A called file can in turn call another file, but eventually the run unit will climb the return stack back to the original caller. The way you setup your run unit is to execute another file with no hope of ever returning.

As previously mentioned an exit statement in any of the called files will prematurely end the entire run unit.

Code: [Select]C:
CD\DIR\SUBDIR
call 1.BAT
REM --- 1
call 2.BAT
REM --- 2
call 3.BAT
REM --- 3
...
...
call 28.BAT
REM --- EOF ---

Hope this helps. THANKS FOR THE REPLIES!!!
more info:


the 1.bat file contents:

C:\DATAIN~1/bin/AL_RWJ~1.EXE "C:\DataIntegrator/log/justice_server/" -w "INET:URANUS:3511" -C "C:\DataIntegrator/log/JOB_CMT_Act_Remark.txt"

(no exit listed...)

I tried adding CALL in front of 1.bat (CALL 1.bat), and that allowed job 2 to start...

now it appears hung...

(which is possible as the Data Integrator product is close on ram)




the REAL gory detials: [JOB_CMT_translate.bat = 1.bat (in my example)]



REM *** batch job to execute a bulk load ***
REM mrbill 5/29/08 (run)
REM job order matters!!!
REM -----------------------------------------
C:
CD\DataIntegrator\Log
rem ----------------- start ----
call JOB_CMT_translate.bat
rem ----------------- 1 ----
call JOB_CMT_defendant.bat
rem ----------------- 2 ----
call JOB_CMT_Collection.bat
rem ----------------- 3 ----
call JOB_CMT_Count.bat
rem ----------------- 4 ----
call JOB_CMT_Remarks.bat
rem ----------------- 5 ----
call JOB_CMT_Def_Desc.bat
rem ----------------- 6 ----
call JOB_CMT_Activity.bat
rem ----------------- 7 ----
call JOB_CMT_Act_Remark.bat
rem ----------------- 8 ----
call JOB_CMT_Sentence.bat
rem ----------------- 9 ----
call JOB_CMT_Bond.bat
rem ----------------- 10 ----
call JOB_CMT_Bond_Remark.bat
rem ----------------- 11 ----
call JOB_CMT_Sentence_Prov.bat
rem ----------------- 12 ----
call JOB_CMT_Witness.bat
rem ----------------- 13 ----
call JOB_CMT_Related_Case.bat
rem ----------------- 14 ----
call JOB_CMT_Appeal.bat
rem ----------------- 15 ----
call JOB_CMT_App_Remark.bat
rem ----------------- 16 ----
call JOB_CMT_Arrest.bat
rem ----------------- 17 ----
call JOB_CMT_Attorney.bat
rem ----------------- 18 ----
call JOB_CMT_Sc_Event.bat
rem ----------------- 19 ----
call JOB_CMT_Add_Sch_Cnts.bat
rem ----------------- 20 ----
call JOB_CMT_Remark_Note.bat
rem ----------------- 21 ----
call JOB_CMT_Add_Remark.bat
rem ----------------- 22 ----
call JOB_CMT_Def_Note.bat
rem ----------------- 23 ----
call JOB_CMT_Evidence.bat
rem ----------------- 24 ----
call JOB_CMT_Alias.bat
rem ----------------- 25 ----
call JOB_CMT_Custody.bat
rem ----------------- 26 ----
call JOB_CMT_Sheriff_Note.bat
rem ----------------- 27 ----
call JOB_CMT_Warrant.bat
rem ----------------- 28 ----

REM ))))))))) all done )))))))))))))))))

rem *********************** end of job *******
Quote
I tried adding CALL in front of 1.bat (CALL 1.bat), and that allowed job 2 to start...

now it appears hung...

The calls are appropriate. The sequence of events so far would be, control.bat starts which in turn calls 1.bat which executes C:\DATAIN~1/bin/AL_RWJ~1.EXE. When the latter is finished, control reverts back to 1.bat which has no more instructions, so control reverts back up the chain to control.bat which then calls 2.bat.

The numbered (1.bat, 2.bat, etc) batch files do not terminate until the exe file being executed is ended. My guess is that the DataIntegrator program is the source of the hangup.

Batch files are containers for instructions you can duplicate at the command prompt. Try entering the control.bat commands MANUALLY at the prompt and see how things go. Liberal use of echo on is recommended until you get the run unit working.

Any reason you need all these batch files? Could you run the RJW programs directly from control.bat?

Hope this helps.



Discussion

No Comment Found