I would also mention that the script also works when executed from the namenode.