Other more sophisticated option: be able to execute the script from an external machine. The problem is certain Hadoop support would be needed in terms of API/libraries in that external machine... complex to deal with that.

I agree on checking the script is being executed in the namenode, exiting otherwise.