PDA

View Full Version : Execute Batch-File (OS windows)



kettle_anonymous
04-11-2006, 08:32 AM
I want to execute a batch file. I used the Shee-Function.
After that I want to make a transformation.


Transformation-->File Exist-->Shell (call.Bat)--> Transformation



My Problem: The Batch-File will not return, so the next transformation will not start.



Can I Use the evaluation-Funtion? How?
Which problem do I have?



thx a lot,



Sven

MattCasters
04-11-2006, 09:34 AM
Hi Sven,

.bat files are the worst! The main thing to remember is to make sure that the .bat file does *not* put anything out on the std output.

@echo off and redirect all output from applications to a logfile or something.

Evaluation is basically a piece of JavaScript that need to end with a condition.
This is the boolean result of the evaluation (true of false: green or red arrow)

The fields to use in your evaluation are described in paragraph 7.2.10 of the Chef manual : Chef-2.2.2.pdf in the Documentation section.

Hope this helps,

Matt

jbleuel
04-11-2006, 11:04 AM
Hi Sven,

calling batch files with shell needs the good old dos command processor ;-)

shell ("command.com /c call.bat")

Mind the "/c" that lets the shell close after finishing the call.bat.
Also ensure command.com is found in the path or add the path like: shell ("C:\path1\command.com /c C:\path2\call.bat")

Thanks for rembering me to my first DOS 1.1 adventure a long time ago with no hard drive but two disk drives in my PC ;-)

Cheers,
Jens

jbleuel
04-11-2006, 11:56 AM
Reply to my self:

I just tested this with Chef - a simple c:\test.bat works, also without the command.com and also with giving output (BTW: I didnÂÂ't get started this with c:\windows\system32\command.com may be "/c" is converted to "\c" also in parameters?).

my simple test.bat:
@echo off
echo o.k. >c:\ok.txt

Could you post your batch?

Cheers,
Jens

MattCasters
04-11-2006, 12:33 PM
Yes, but this bat file is NOT producing output.
Put something like

echo TheDailyWTF: Brillant

in there, and it will not return. (last time I checked :-))

Cheers,
Matt

kettle_anonymous
04-12-2006, 04:37 AM
Hi,

i tried do call one sql-File wiht sqplus, which was generated from another tool.
The batch-File is like this

@echo off
command.com /c sqlplus XXX/XXX@DB @my.sql >logfile.log

The Header of the my.sql ist like

set feednack off
set echo off
set termout.off

A lot of Create External-table-Statements

In the future i want our company to use spoon Text file input. But in this project i have to use the external tables but i want Kettle for the outher operations.

Thx a lot,

Sven

MattCasters
04-12-2006, 04:47 AM
That should work.
Did you check that the my.sql has an "exit" statement at the back?
Otherwise it will indeed stay blocked inside sqlplus.

Matt