-1

Scenario: There are a large number of repositories and 3rd party programs which I install whenever I freshly install Linux on my machine, and the process (including config) often takes half a day. I install these programs using the Advanced Package Tool, and I'm trying to automate this process.

Problem: APT will usually prompt the user to input the keypress 'Y', to confirm an installation, and I am wondering how I would use a Bash script to automate this keypress so that the script can proceed with installation without any human interaction.

Example of keypress:

0 to upgrade, 2 to newly install, 0 to remove and 8 not to upgrade.
Need to get 202 kB of archives.
After this operation, 736 kB of additional disk space will be used.
Do you want to continue? [Y/n] y

Specifications: I have considered condensing all the apt-get installations into a single apt-get system call (which is possible), however I want the program to record the success of each installation by monitoring return codes.

I should specify; the keypress will occur during the execution of the system call for: apt-get install **application**, and I am unsure whether another scripting language such as Ruby or Python might not be better suited to this task.

Thanks in advance.

jww
  • 97,681
  • 90
  • 411
  • 885
user4493605
  • 391
  • 2
  • 18

2 Answers2

1

apt-get very specifically has a -y option to allow you to bypass interactive prompting.

tripleee
  • 175,061
  • 34
  • 275
  • 318
-1

I think you can just use

yes | sudo apt-get install ...

Of course, you need to have it set up so that you don't have to enter your password.

chw21
  • 7,970
  • 1
  • 16
  • 31