Wait for remote process to finish

hi, have a look at this thread, i was just solving the same problem, maybe something will help you