Wait till a shell script is completed


I am building a BPMN which triggers an api to clone a machine ( using camunda connect). This is working fine and the cloning process starts.

I have written a shell script to monitor that the machine has become live after cloning


while ! timeout 1 bash -c “echo > /dev/tcp/$1/22”; do
sleep 1

echo “up”

This is a script task in groovy, meaning I call this shell script from groovy

static void main(String args) {
def sout = new StringBuilder(), serr = new StringBuilder()
def ip = execution.getVariable(“field_private_ip”)
def cmd = [“/opt/gasf/scripts/wait_for_cloning.sh”, ip]
println “Command:$cmd”
def proc = cmd.execute()
proc.consumeProcessOutput(sout, serr)
println “out> $sout err> $serr”

The shell script that I am calling technically waits till it is able to establish connection and only then returns a value.
When I run this via the process engine, the script task is triggered and passes to the next task.
Is there a way that I could make execution wait at this script task until it is successful ?

Advice would be much appreciated.

@Rajiv_Cj see: Shell Script Invoked by Camunda

The thread discusses how the timeouts for a activity functions in the engine. There is also a “potential” workaround (not fully tested, and unclear what the implications might be).

Hello @StephenOTT, In groovy in gave a “waitForProcessOutput()” and it waits till the script gets an output.

I have however followed your method and setup a receive task, so now, my shell script does a call back to the engine using curl


curl --request POST --url http://localhost:8080/engine-rest/message --header "Accept: application/json" --header "Content-Type: application/json" --data "$data"

But, now I am not sure what to do to get this process running in the background.

I tried async before, but did not work. Could you help me get this script task run in the background?

Thank you