Monday 6 May 2013

Shell Script File for Checking Package Installed or not Or If not then Install Package - For Ubuntu OS

Dpkg: check that unix package is installed. Bash script: install package if not present

dpkg -s can be used.
Example: is vlc installed?
> dpkg -s vlc|grep installed
Here is some logic in bash script, like installing package if it is not there:
1
2
3
4
5
6
problem=$(dpkg -s vlc|grep installed)
 echo Checking for libxul: $problem
 if [ "" == "$problem" ]; then
      echo "No libxul. Setting up libxul"
      sudo apt-get --force-yes --yes install vlc
 fi

No comments:

Post a Comment