2

I've created my script to install software on a new computer. Basically it includes lot's of

apt get install <pkg name> -y

lines.

How can I get a short report about installs that has failed?

Is there a function like that in bash?

1 Answer 1

3

Combining the following two basic things in scripting might help you out here.

  • Check exit status codes of your commands. A non-zero number means that something has gone wrong usually and the value itself might have a meaning (check documentation of your program returning those). See this howto: "Exit and Exit status" on how to do that in Bash.
  • Redirect errors - usually sent to stderr - to a temporary file. See this how-to: "I/O Redirection" on how to do that in Bash. Show that file if any of your commands returned an error.

While diverging from your question to do this in Bash, more opportunities lie elsewhere.

Higher-level approaches of automated installation using APT aren't really possible in Bash as far as I know. You could consider using Puppet, preseeding the Debian/Ubuntu installer for automated deploying or to start writing in a more powerful language like Python that features APT bindings, e.g. python-apt.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .