I'm really curious what the underlying purpose it to write this script/task? It's sounds like trying to automate a task that was more or less deliberately set up to require manual intervention?
_________________________
There are two types of vessels, submarines and targets.