running multiple jobs from a batch file in pentaho - batch-file

I would like to ask if there is a more efficient way of running multiple transformations(70 transformations) besides the IDE? Doing it the IDE way is alright but it does become tedious having to click all the tabs and the hidden tabs as well.
What I did was I tried using the pan.bat command and placed it in a bat file. The bat file would look like this:
cd <to dest of kitchen.bat>
pan.bat <mytransformation 1>
pan.bat <mytransformation 2>
pan.bat <mytransformation 3>
pan.bat <mytransformation 4>
But it only works on the first transformation and then it quits. Am I doing something wrong or what options do I have to run multuple transformations from script

Thats what a JOB is for. Create a Job (or jobs) to run these transformations and execute with kitchen not pan.
You can also dynamically execute KTR's if you want to as well. i.e. execute all KTRs in a given folder etc.
Running via a job should be marginally faster too as you're not starting and stopping the entire VM every time. (which is surprisingly expensive)
Additionally running via a job gives you control over error handling, parallelisation and sequencing.

When calling a batch file from another, you have to use the call command, otherwise (as you found) it transfers control to the new batch file permanently.
call pan.bat <mytransformation 1>
call pan.bat <mytransformation 2>
call pan.bat <mytransformation 3>
call pan.bat <mytransformation 4>

Try this:
pan.bat "mytransformation 1"
.. or:
start /b "" "pan.bat" "mytransformation 1"

You can combine all transformations as a single or 2 jobs then call the job this is a efficiency way to call the all transformations in single job.
In pentaho by default jobs are running sequence mode if you want run parallel mode you can easily

Related

Start multiple JavaScript files and wait for them to finish

I am building a program that outputs a batch file. In this batch file there are some links to JavaScript files, which are then supposed to run within photoshop.
Most of it works, but I just want the next JavaScript to run when the previous one is finished! Is this possible?
Yes, this is certainly possible using start with the /wait flag, telling the system to wait to finish a command before processing the next command. Run each file with:
start "" /wait node something.js [arguments]
It is suggested for you, to read the output of start /? carefully in cmd.exe.

Using call <file.bat> results in "sleep is not recognized as an internal or external command.."

I have a script that calls other commands in a for loop:
for %%x in (%CMDS::= %) do (
call C:\%%x %1%
echo "%%x complete"
)
However, running this results the console spitting out :
'sleep' is not recognized as an internal or external command,
operable program or batch file.
This is because the files i loop through and run have these commands in them. Why is it that if i run these files one by one they work, but when chained using call they don't? I can sleep in my terminal outside of this script..
Regards
Thanks to another answer, I solved this error by replacing sleep 5 in my .bat file with:
powershell -Command "& {sleep 5}"
Works fine now. Better still, also tested Stephan's suggestion:
timeout 5
Simpler, and shows a nice message like
Waiting for 0 seconds, press a key to continue ...
Note that some Windows versions require the /t option to define the time.
timeout /t 5
There is no sleep command in batch. That's why you are getting this error.
EDIT:
There is no sleep command in Windows CMD or Batch. BUT: as you can use the command in your console, I suppose there might be a script or a program called sleep. This script or program might be situated in your working directory or in some other directory included in your %PATH% variable. If this is the case, it's possible that your script gives you this error because of a path issue.
Say, you are in C:\SomeFolder and there is a sleep.exe in there. You are calling another script or command which changes the current directory to D:\AnotherFolder. Now another script or command tries to execute your mysterious sleep command assuming the working dir to be C:\SomeFolder but as you are in a different folder (D:\SnotherFolder) now, sleep can't be found. Further, when using call the variable scope of the calling script becomes also the scope for the called script. So it's also possible that variables are being overwritten by different scripts. Such a variable might contain the path to your sleep command. This could also cause an error.

Batch script is not executing another batch if I run from jenkins

I have installed Jenkins 1.55 exe in windows environment. I have a build script*.bat) which internally calls another (.bat). While executing manually it is working fine but while trying in jenkins only first batch script is executing without triggering the second one and it is giving as success.
Is there any solution for this?
D:\Jenkins\workspace\9.0_TP_Build>cd D:\PortalScripts\9000 portal\
D:\PortalScripts\9xxx portal>WL9.0-TPRefresh-doPortalNightlyBuild2.bat ---> THis is the file i am executing
D:\PortalScripts\9xxx portal>cd d:\PortalScripts\axxx portal
D:\PortalScripts\9xxx portal>call WL-9000-TPRefresh-BuildPortal.bat a.x.x.x axxx axxx --> THis is the second file needs to be executed...but the below echo are from the first batc files...
D:\PortalScripts\9xxx portal>REM #echo off
D:\PortalScripts\9xxx portal>SET HR= 5
If you call a batch file from another, the first one will exit after executing the 2nd one, unless it is called with "call". For example:
call WL9.0-TPRefresh-doPortalNightlyBuild2.bat
instead of just:
WL9.0-TPRefresh-doPortalNightlyBuild2.bat
There is a similar question/answer here, with an example: Batch Closing before end of file?

Run batch files sequentially

I want to ask you all how to run batch files sequentially in Windows.
I have tried :
start /w batchfile_1.bat
start /w batchfile_2.bat
..
start /w batchfile_n.bat
but I have to close the previous .bat file process manually (e.g. by clicking) before continuing into the next one.
Is there any solution to do this automatically without me doing the manual closing previous .bat program every time?
Thanks a lot.
I would check the solutions to this question: Run Multiple batch files
Taken from the answer in the link.
Use call:
call bat1.cmd
call bat2.cmd
By default, when you just run a batch file from another one control will not pass back to the calling one. That's why you need to use call.
Basically, if you have a batch like this:
#echo off
echo Foo
batch2.cmd
echo Bar
then it will only output
Foo
If you write it like
#echo off
echo Foo
call batch2.cmd
echo Bar
however, it will output
Foo
Bar
because after batch2 terminates, program control is passed back to your original batch file.
If you are in love with using START, you could have your batch files end with the EXIT command. That will close the windows created by the start command.
#echo off
.
.
:: Inspired coding
.
.
exit
I'm not sure but based on your comments, the following seems to be happening when you run that sequence of START commands:
A START /W command is invoked and starts a batch file.
The batch file starts executing and runs a program.
The batch file finishes and its console window remains open, but the program continues running.
The START /W command that was used to run the batch file is still executing because the console window remains open.
You wait until the program terminates, then you close the console window, and then the next START /W command is invoked, and everything is repeated.
Now, if you place EXIT at the end of every batch file you want to run sequentially, that makes situation worse because it causes the console window to close after the batch script completes, and that in turn ends the corresponding START /W command and causes another one to execute, even though the program invoked by the batch script may still be running. And so the effect is that the batch scripts (or, rather, the programs executed by them) run simultaneously rather than sequentially.
I think, if this can be solved at all, you need to move the START /W command and put it in every batch file in front of (every) command that that batch file executes and doesn't wait for the termination of. That is, if your batchfile_1.bat runs a program.exe, change the command line to START /W program.exe, and similarly for other relevant commands in other batch files.

Batch script stops after first call to other batch script

I'm attempting to execute a batch script that currently looks like this:
D:
cd D:My Documents\FtpSolution\Test
getftp.bat
call delimconvert.exe
call convert-to-xls.bat
However this stops dead after getftp.bat has run.
What am I doing wrong? It's important that these commands all run sequentially.
Use call:
Calls one batch program from another.
CALL [drive:][path]filename [batch-parameters]
batch-parameters Specifies any command-line information required by the
batch program.
If you invoke other batch files without call then control is passed to them but not back again (which is what call changes).
use start command to launch it in a new window.
start /wait getftp.bat
Try using "Goto :EOF" rather than "exit" at the end of the batch file that you're calling - in your case, the getftp.bat file...
That's what fixed mine - tested on Win10 enterprise.

Resources