sudo の -p オプションは、パスワードではなくプロンプトを指定します。-A オプションを見てください。sudo man ページからの抜粋:
-A Normally, if sudo requires a password, it will read it from the current
terminal. If the -A (askpass) option is specified, a
helper program is executed to read the user's password and output the
password to the standard output. If the SUDO_ASKPASS environment variable
is set, it specifies the path to the helper program. Otherwise, the value
specified by the askpass option in sudoers(5) is used.
ヘルパー プログラムは、正しいパスワードを出力する必要があります。したがって、ヘルパー プログラムを指定するには、次のようにします。
export SUDO_ASKPASS="/path/to/helper"