Skip to main content
Solved

Running a .bat file in FME Desktop workspace


vxn43
Supporter
Forum|alt.badge.img+18

I have a batch file (.bat) that I need to run. What Transformers would I need to use to get this to run using a workspace in FME Desktop?

Best answer by virtualcitymatt

hkingsbury wrote:

You could just leave it with the two transformers, but a better approach might be to include some error capture.

 

for example, the SystemCaller caller might successfully call the .bat file, but the .bat file fails to run and you get a nonzero exit code. Your workbench will show as having run successfully (because fundiemntally it did). What you could include is a Tester that tests for a 0 exit code and passes that to a logger which says 'Success'. Is cases where the exit code isn't 0, you can then pass it to a Terminator which will terminate the workbench, showing as a failure

Yes 100% this is the best workflow here

Creator > SytemCaller > Tester (_exit=0) > (Logger pass|Terminator fail)

View original
Did this help you find an answer to your question?

6 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

You can use the SystemCaller to do this. It can be initiated by anything. If you don't have anything to initiate it, you can always use a Creator to initiate it.


vxn43
Supporter
Forum|alt.badge.img+18
  • Author
  • Supporter
  • July 3, 2023

Using the SystemCaller, in what situations do I need to specify an Exit Attribute? is there a list of commonly used Exit Attributes and what they are used for?

 


nielsgerrits
VIP
Forum|alt.badge.img+54
timh wrote:

Using the SystemCaller, in what situations do I need to specify an Exit Attribute? is there a list of commonly used Exit Attributes and what they are used for?

 

You can use it to check if the script did run successfully. From the help:

 

If an Exit Code Attribute is specified, it will be set to the executed program's exit code: usually 0 for success and nonzero for failure.


vxn43
Supporter
Forum|alt.badge.img+18
  • Author
  • Supporter
  • July 3, 2023

Thanks, this is super helpful.

One last question, which I am sure is an easy answer, my workspace to run the batch file includes the Transformers, I have not run it yet, but I have CREATOR --> SYSTEMCALLER --> ??? what Transformer would you recommend I include after SYSTEMCALLER? This would be my last Transformer in the workspace. My goal is to just have the .bat file run. I am thinking of using the Logger Transformer?


hkingsbury
Celebrity
Forum|alt.badge.img+53
  • Celebrity
  • July 4, 2023
timh wrote:

Thanks, this is super helpful.

One last question, which I am sure is an easy answer, my workspace to run the batch file includes the Transformers, I have not run it yet, but I have CREATOR --> SYSTEMCALLER --> ??? what Transformer would you recommend I include after SYSTEMCALLER? This would be my last Transformer in the workspace. My goal is to just have the .bat file run. I am thinking of using the Logger Transformer?

You could just leave it with the two transformers, but a better approach might be to include some error capture.

 

for example, the SystemCaller caller might successfully call the .bat file, but the .bat file fails to run and you get a nonzero exit code. Your workbench will show as having run successfully (because fundiemntally it did). What you could include is a Tester that tests for a 0 exit code and passes that to a logger which says 'Success'. Is cases where the exit code isn't 0, you can then pass it to a Terminator which will terminate the workbench, showing as a failure


virtualcitymatt
Celebrity
Forum|alt.badge.img+35
hkingsbury wrote:

You could just leave it with the two transformers, but a better approach might be to include some error capture.

 

for example, the SystemCaller caller might successfully call the .bat file, but the .bat file fails to run and you get a nonzero exit code. Your workbench will show as having run successfully (because fundiemntally it did). What you could include is a Tester that tests for a 0 exit code and passes that to a logger which says 'Success'. Is cases where the exit code isn't 0, you can then pass it to a Terminator which will terminate the workbench, showing as a failure

Yes 100% this is the best workflow here

Creator > SytemCaller > Tester (_exit=0) > (Logger pass|Terminator fail)


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings