Testing for Program Installation on Linux

WJG (28/10/16) The simplest way to check for the installation of a program in Linux is to use the which command. Checking to see if, lets say LibreOffice, is installed then typing which soffice in a terminal will result in the installation path of the program being returned, i.e. '/usr/bin/soffice', or nothing. Knowing this, it's possible to wrap the which command into a handy proc using the exec Tcl command.

proc is_installed { prog } {
        set res 0 
        # trap "abnormal" termination
        catch { if { [exec which $prog] != "" } { set res 1 } } 
        return $res
}