Very often from TCL scripts we may want to execute external commands.
But not always they also available, sometime the command that we want to execute may not exist on the respective machine.
One solution is to put the exec command in a catch { exect $your_command $arg1 $arg2 … } and then to check if it was successfully.
The problem here is that you have to write few lines of code to check if the command is missing, or the arguments passed were wrong.
Other solution, more elegant I think, is to use auto_execok procedure to check if your command really exists, something like bellow:
% set ls_cmd_path [auto_execok ls] /bin/ls % puts $ls_cmd_path /bin/ls % set ls_cmd_path [auto_execok ls_wrong] % puts $ls_cmd_path %
So, just call the set result [auto_execok $your_command] and check if the result is not empty string to see if the command really exists.