Phil Trubey
ph...@netpart.com
--
>Is there a way of creating a unique temporary filename in tcl?
>I'm used to using the $$ construct from sh, but I can't seem to
>find anything like that in TCL. Thanks!
set tempfilename "prefix[pid]"
--
Joe V. Moss | j...@morton.rain.com
Morton & Associates | jo...@m2xenix.psg.com
7478 S.W. Coho Ct. | - or -
Tualatin, OR 97062-9277 | uunet!m2xenix!morton!joe
Well, you could make up some scheme for generating file names and
checking for uniqueness/existance. Maybe something like:
proc TempFile {prefix} {
set i 0
while {[file exists [set theFile ${prefix}_$i]]} {incr i}
return ${prefix}_$i
}
set tmpfile [TempFile /tmp/[pid]]
Or, maybe your system already has a command for doing it. Under
HP-UX, there's mktemp. It has a few options for specifying a
directory, prefix, etc., but it pretty much gets the job done
by just saying in Tcl:
set tmpfile [exec mktmp]
I honestly don't know if mktemp is some obscure HP-UXism, or if
its the most common command on the planet. The Tcl proc above
would probably be much faster (unless "i" if forced to grow large),
but the mktemp command is bit more flexible. Your choice...
Sincerely,
--------------------------------------
Thomas J. Accardo t...@cpu.com
Computerized Processes Unlimited, Inc.
Metairie, LA
Voice (504) 889-2784
FAX (504) 889-2799