How would I write a script that searches for and installs Linux software?

Vincent S September 12, 2014
Pinterest Stumbleupon Whatsapp
Ads by Google

I was wanting to write an Ubuntu bash shell script that would allow a user to search for a program like (apt-get search). I’d like the script to allow users to input¬†the name of the program they are looking for and then be prompted to install the file that the search pulls up.

The search would be from the Internet and would prompt what file to install.

How would I get started writing such a script?

  1. dragonmouth
    September 12, 2014 at 12:48 pm

    apt-get already does that. Then there is Software Center or Synaptic.

    I agree with Jan. If you have to ask how to write such a script, you do not enough expertise in script writing.

  2. Jan F
    September 12, 2014 at 6:31 am

    Well, isn't that what aptitude is doing already? You tell it what program you want to install and it will automatically install all dependencies along with it.

    For things outside aptitude doing so seems quite courageous. Your "script" would have to search the web using a database e.g. Google, would have to select the fitting result (which is not always the first one), navigate through a website with an unknown structure and finally download the file intended for the system you are running.

    If you have to ask how to start writing such a script I'm afraid I have to say you are set to fail.

    If you look at tools like Ninite or aptitude itself they use predefined "lists" to know what to download and where from and still rely on the download source to provide and easy way to get em e.g. a "latest version" download link too. For example if there is no dynamic download for the latest version and the download file name/link changes duo to versioning you already have to adjust your script every time a new version is released.