Storing sudo password as variable in script - is it safe?

Viewed 9924

Is storing my password this way safe?

echo 'Write sudo password (will not be displayed) and hit enter'
read -s password

I need it to make commands like this:

echo $password | sudo -S apt-get install -y foo bar
4 Answers
Related