util::which (public)

 util::which prog

Defined in packages/acs-tcl/tcl/utilities-procs.tcl

Use environment variable PATH to search for the specified executable program. Replacement for UNIX command "which", avoiding exec. exec which: 3368.445 microseconds per iteration ::util::which: 282.372 microseconds per iteration In addition of being more than 10 time faster than the version via exec, this version is less platform dependent.

prog - name of the program to be located on the search path
fully qualified name including path, when specified program is found, or otherwise empty string
Gustaf Neumann

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_admin_exec_dependencies acs_admin_exec_dependencies (test acs-admin) util::which util::which test_acs_admin_exec_dependencies->util::which test_acs_tcl_exec_dependencies acs_tcl_exec_dependencies (test acs-tcl) test_acs_tcl_exec_dependencies->util::which test_xotcl_core_exec_dependencies xotcl_core_exec_dependencies (test xotcl-core) test_xotcl_core_exec_dependencies->util::which test_xowiki_exec_dependencies xowiki_exec_dependencies (test xowiki) test_xowiki_exec_dependencies->util::which ad_file ad_file (public) util::which->ad_file Object ::throttle Object ::throttle (public) Object ::throttle->util::which acs_admin::check_expired_certificates acs_admin::check_expired_certificates (private) acs_admin::check_expired_certificates->util::which apm_transfer_file apm_transfer_file (private) apm_transfer_file->util::which bootstrap_icons::download bootstrap_icons::download (private) bootstrap_icons::download->util::which db_get_pgbin db_get_pgbin (public) db_get_pgbin->util::which

acs_admin_exec_dependencies, acs_tcl_exec_dependencies, xotcl_core_exec_dependencies, xowiki_exec_dependencies
Source code:
    switch -- $::tcl_platform(platform) {
        windows {
            # Notice: Windows has an alternative search environment
            #         via registry. Maybe it is necessary in the future
            #         to locate the program via registry (sketch below)
            # package require registry
            # set key {HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths}
            # set entries [registry keys $key $prog.*]
            # if {[llength $entries]>0} {
            #   set fullkey "$key\\[lindex $entries 0]"
            #   return [registry get $fullkey ""]
            # }
            # return ""
            set searchdirs [split $::env(PATH) \;]
            set exts       [list .exe .dll .com .bat]
        default {
            set searchdirs [split $::env(PATH) :]
            set exts       [list ""]
    foreach dir $searchdirs {
        set fullname [ad_file join $dir $prog]
        foreach ext $exts {
            if {[ad_file executable $fullname$ext]} {
                return $fullname$ext
    return ""
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:

[ hide source ] | [ make this the default ]
Show another procedure: