installing programs from the bash script

21,985

Solution 1

First of all, you can use

sudo apt-get install pkg1 pkg2 ... pkg3

and next, with the option -y, apt-get will not ask for confirmation.

Solution 2

The yes command is useful here

yes | ./install_script.sh
Share:
21,985

Related videos on Youtube

Pushpak Dagade
Author by

Pushpak Dagade

My LinkedIn profile: https://in.linkedin.com/in/pushpak-dagade-47275121

Updated on September 18, 2022

Comments

  • Pushpak Dagade
    Pushpak Dagade almost 2 years

    I wish to install a large number of programs from the software center on all my 8 machines. Installing each program individually would be time consuming so I decided to write a bash script for installing all these programs in 1 go. It looks something like this -

    #! /bin/sh
    apt-get install xyz1
    apt-get install xyz2
    apt-get install xyz3
    

    (Am running this script as a super user)

    Now the problem is that for almost every installation it asks me ..need to get 123 kb of archives. Continue [Y/n] ? Every time I have to select Y(yes) myself.

    Is there some way in which I can override this confirming mechanism so that I don't have to press y everytime?

  • Pushpak Dagade
    Pushpak Dagade almost 13 years
    If installation of some package, say pkg2 fails, will the installation of remaining packages still continue?
  • enzotib
    enzotib almost 13 years
    This is hard to say, it depends on the reason of fail, I think. But it not change in the "multiline" approach, because if there is a reason blocking the package manager, it will be so also in a separate command.
  • Pushpak Dagade
    Pushpak Dagade almost 13 years
    Thank you. And what if some pkg depends on some other package not already installed? Will it install the dependencies as well?
  • enzotib
    enzotib almost 13 years
    Yes, of course it will select for installation dependencies and recommended packages too.
  • Thomas Ward
    Thomas Ward almost 13 years
    The one thing to consider is that if a dependency is being installed, and then fails, that it will fail to install any of the packages that depend on that (i.e. if pkg2 depends on pkg1, and pkg1 fails, pkg2's install fails)