If I understand correctly what you are trying to do, are you putting that
sudo command into the script and expecting the script to prompt for your password when it runs there? In that case you are just doing things the complicated way.
A cleaner solution is to write the script in the usual way (i.e without
sudo) and run it as the superuser. The reason behind this is, if the script needs superuser access, then just give it the access (why wait until a certain command?). In the script, to check if it is being run as root do something like this:
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2