sudo displays typed password in bash script
- by Andy
Hullo,
I have a bash script that uses sudo a few times. There's a couple of strange points about it though.
It asks me for my password a few seconds after I've already entered it for a previous command.
The second time I enter my password, it's echoed to the display.
Here's the relevant bits of the script.
sudo service apache2 stop
drush sql-dump --root="$SITE_DIR" --structure-tables-key=svn --ordered-dump | grep -iv 'dump completed on' | sudo tee "$DB_DIR/${SITE_NAME}.sql" > /dev/null
sudo svn diff "$DB_DIR" | less
sudo svn commit -m "$MESSAGE" "$DB_DIR"
sudo service apache2 start
The first password is to stop apache, and it works as expected. As mentioned, the sudo tee doesn't 'remember' that I have elevated privileges, asks for the password again, and echoes it to the screen. Given that tee is all about echoing to screen, I've played around a little with simple scripts which have | sudo tee, and they all work as expected.
Ideas?! TIA
Andy