tags:

views:

55

answers:

4

Is there a possibility to get the full path of the currently executing TCL script?

In PHP it would be: __FILE__

A: 

seconds after I've posted my question ... lindex $argv 0 is a good starting point ;-)

Informant
I think you'll be disappointed with that. You'll get the first argument after the filename. If you do "tclsh foo.tcl one two" argv will be a list like ["one" "two"]
Bryan Oakley
+2  A: 

You want $argv0

glenn jackman
if accessing from a procedure, either define argv0 as global, or fully qualify it as `$::argv0`
Bryan Oakley
Note that the global `argv0` variable is a feature of tclsh and wish (and tclkit too) and not of Tcl in general. It's very common though; the support function `Tcl_Main` implements it for you…
Donal Fellows
+3  A: 

Depending on what you mean by "currently executing TCL script", you might actually seek info script, or possibly even info namefexecutable or something more esoteric.

Cameron Laird
+2  A: 

You can use [file normalize] to get the fully normalized name, too.

file normalize $argv0
file normalize [info nameofexecutable]
RHSeeger