#!/bin/sh # the next line restarts using wish \ exec tclsh "$0" "$@" set pname "vtmp" ##### program minimal tcl template with tmp files #### version V0.6, includes tmp file management #### -v for verbose mode (all to stderr) #### -d more verbose plus puts tmp file in local dir and does not delete #### set ntemp to number of temp files requried #### use pexit to remove tmp files set of "" set r [eval "exec vtkparse if= of= -v - with $pname $argv"] eval $r if { [info exists OPT ] } { puts "$pname: template for vx tcl script " puts {[if= ] input map file} puts {[of= ] output file} puts {[-v ] verbose mode} puts {[-d ] debug mode} exit } set optv [info exists OPTv] set optd [info exists OPTd] if { $optd } { set optv 1 } #create ntemp intermediate file names set tm "/tmp/tm.$pname[pid]" if { $optd } { set tm "./tm.$pname[pid]" } set ntemp 1 set ti 1 while { $ti <= $ntemp } { set tm$ti ${tm}.$ti incr ti } ### use pexit instead of exit to remove tmp files proc pexit { rcode } { global ntemp tm optd set ti 1 if { !$optd } { while { $ti <= $ntemp } { file delete -force ${tm}.$ti incr ti } } exit $rcode } ### main if { $optv } { puts stderr "exec vcp if=$if of=$of" } exec vcp if=$if of=$of pexit 0