I would like to call/execute a shell script from a mule flow asynchronously . Also would like to know if we can call/execute a bat script
Asked
Active
Viewed 1,041 times
1 Answers
0
Yes, you could, in fact anything you can do with plain old Java you can do with Mule using the Java component.
Create a Java component and place it within Async scope
Here a snippet of code to call a shell script using Java this answer expands on it
ProcessBuilder pb = new ProcessBuilder("myshellScript.sh", "myArg1", "myArg2");
Map<String, String> env = pb.environment();
env.put("VAR1", "myValue");
env.remove("OTHERVAR");
env.put("VAR2", env.get("VAR1") + "suffix");
pb.directory(new File("myDir"));
Process p = pb.start();
-
Is there any out of box component to call a script in mule ? – Naveen Raj Sep 07 '15 at 17:09
-
Most of the Mule components correspond to the EIP patterns a few others are hooks for custom logic, calling shell script is custom logic and so you won't find a mule processor just to do that, you could possibly write your own though – Sudarshan Sep 07 '15 at 17:25
-
Having understood that mule is corresponding to EIP (which I am little aware already)which states how an endpoint can be constructed and how routing,validation,filters can be done. I wanted to know if there were any endpoints conforming to EIP standards to call or execute a system call to run a shell script or a bat file in mule already ?. From your comment I understand we don't have it . Please confirm you are aware of it. – Naveen Raj Sep 08 '15 at 05:38
-
Ya, I can confirm that – Sudarshan Sep 08 '15 at 06:17