Adding sudo in the script before each cp command did the trick.