我写了一段代码,只有当目录中存在某个文件时才创建菜单,一旦找到文件,菜单就安装在tcl UI中。 我正在提取文件名并逐行读取以安装菜单,它运行良好但我想打开此文件以便在UI中单击新安装的菜单按钮时查看。
我试过命令{exec emacs $rundir/$line}
,但它没有用。
$rundir is /home/abc
$line is filename= example.log
这是我的代码:
proc get_lib2cpf_results {} { ## procedure
type_run
global rundir typep logfile line
cd $rundir
if {[file exists $rundir/check_syntax_$typep.sh] == 0 } {
tk_dialog .dialog1 "File didn't exist" info 0 OK
} else {
exec cat $rundir/check_syntax_$typep.sh | awk {{print $13}} > file_$typep.txt ### finding a file in a rundir
.mbar.dm add cascade -label "LOGFILE(s)" -menu .mbar.dm.sb -underline 1
menu .mbar.dm.sb #### creating a menu entry
set f [open $rundir/file_$typep.txt] ### reading file line by line
while {1} {
set line [gets $f]
if {[eof $f]} {
close $f
break
}
puts "Read line: $line"
puts "Logfile is present at $rundir/$line"
.mbar.dm.sb add command -label $line -underline 0 -command { exec emacs $rundir/$line] } ### adding menu entry based on $line
}
}
}
请告诉我是否有可能实现这一目标?任何替代方法将不胜感激。