1Tcl_FindExecutable(3) Tcl Library Procedures Tcl_FindExecutable(3)
2
3
4
5______________________________________________________________________________
6
8 Tcl_FindExecutable, Tcl_GetNameOfExecutable - identify or return the
9 name of the binary file containing the application
10
12 #include <tcl.h>
13
14 void
15 Tcl_FindExecutable(argv0)
16
17 const char *
18 Tcl_GetNameOfExecutable()
19
21 char *argv0 (in) The first command-line argument to the pro‐
22 gram, which gives the application's name.
23_________________________________________________________________
24
25
27 The Tcl_FindExecutable procedure computes the full path name of the
28 executable file from which the application was invoked and saves it for
29 Tcl's internal use. The executable's path name is needed for several
30 purposes in Tcl. For example, it is needed on some platforms in the
31 implementation of the load command. It is also returned by the info
32 nameofexecutable command.
33
34 On UNIX platforms this procedure is typically invoked as the very first
35 thing in the application's main program; it must be passed argv[0] as
36 its argument. It is important not to change the working directory
37 before the invocation. Tcl_FindExecutable uses argv0 along with the
38 PATH environment variable to find the application's executable, if pos‐
39 sible. If it fails to find the binary, then future calls to info name‐
40 ofexecutable will return an empty string.
41
42 Tcl_GetNameOfExecutable simply returns a pointer to the internal full
43 path name of the executable file as computed by Tcl_FindExecutable.
44 This procedure call is the C API equivalent to the info nameofexe‐
45 cutable command. NULL is returned if the internal full path name has
46 not been computed or unknown.
47
48
50 binary, executable file
51
52
53
54Tcl 8.1 Tcl_FindExecutable(3)