LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Scripts to respond to prompts (https://www.linuxquestions.org/questions/linux-newbie-8/scripts-to-respond-to-prompts-4175538163/)

coproc 03-29-2015 11:11 AM

Scripts to respond to prompts
 
I have searched and was unsuccessful in finding a quick command or example to use.

I'm looking to automate an update process using command line in Debian.
Normally I'd use apt-get update|upgrade|dist-upgrade .

If apt-get finds a package to update it queries a Y/n response.
My objective is to have a script determine if this prompt is there, and if so to respond with 'Y'.
If not then it should not enter a response.

I know I'll need to use an IF/ELSE function, but what I'm having difficulties locating is to read the output of apt-get .

I know there's books and sites available, but they are all long and sometimes difficult to read or understand. And maybe my keywords are the right ones to use, as I'm not able to pinpoint a solution.

Thanks for your assistance.

unSpawn 03-29-2015 11:16 AM

Quote:

Originally Posted by coproc (Post 5339397)
If apt-get finds a package to update it queries a Y/n response. My objective is to have a script determine if this prompt is there, and if so to respond with 'Y'. If not then it should not enter a response.

So basically you're looking for the ginormously dangerous "just update everything and be done with it" option, as in 'man apt-get': -y, --yes or --assume-yes?..

coproc 03-29-2015 02:17 PM

Since you put it that way, then I guess yes.
And that would answer my post.

However, when I run the update on these, I usually always say Y anyways and haven't had any issues.

Thanks for that quick reply!

joe_2000 03-29-2015 03:17 PM

Take a look at unattended-upgrade. It lets you configure which upgrades should be done automatically.

Note that some upgrades cannot be done automatically because you have to make decisions, e.g. whether or not to update configuration files etc...


All times are GMT -5. The time now is 07:34 AM.