Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
good answer. thanks. –  Tibo Sep 11 '12 at 17:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.