我的代码这一艰巨块:写出的变量文本值到文件
exec zip -r $FULLPATH error.log [ append datetime $RECENT ".bwdb" ] [ append txt $testName ".txt" ] [ append lancap $testName "-lan.cap" ] \
[ append lanmcap $testName "-lan-m.cap" ] [ append wancap $testName "-wan.cap" ] [ append wanmcap $testName "-wan-m.cap" ] [ append conf $confFile ".conf" ] \
start.txt start-lan.cap start-lan-m.cap start-wan.cap start-wan-m.cap [ append comments "comments-" $RECENT ".bwc" ]
这实际上只是荏苒一堆文件一起。我正在改变生成zip文件的方式(更准确地说,当我生成时,我正在更改)。我决定这样做的方式是将每个命令保存到文本文件中,然后在需要创建文件时通过文件中的每个命令。问题是我有一堆我需要转换成文字形式的变量。
有谁知道我该如何将此命令转换为它的文字值并将其存储到文本文件中?
编辑:我也愿意听到其他建议,以解决相同的问题,和/或任何利弊做我的建议。
EDIT2:感谢所有帮助,我选择这样做:
set data123 "exec zip -r $FULLPATH error.log [ append datetime $RECENT \".bwdb\" ] [ append txt $testName \".txt\" ] [ append lancap $testName \"-lan.cap\" ] \
[ append lanmcap $testName \"-lan-m.cap\" ] [ append wancap $testName \"-wan.cap\" ] [ append wanmcap $testName \"-wan-m.cap\" ] [ append conf $confFile \".conf\" ] \
start.txt start-lan.cap start-lan-m.cap start-wan.cap start-wan-m.cap [ append comments \"comments-\" $RECENT \".bwc\" ]"
set datafile123 "datafile123.txt"
set fileId123 [ open $datafile123 "w" ]
puts $fileId123 $data123
close $fileId123
然而,当我看到生成的文件我看到:
exec zip -r /home/IOL/TR069_Certification/Results/TEST_Round99_GetRPCMethods_CDR1_20130410172812 error.log 20130410172812.bwdb20130410172812".bwdb" GetRPCMethods.txtGetRPCMethods".txt" GetRPCMethods-lan.capGetRPCMethods"-lan.cap" GetRPCMethods-lan-m.capGetRPCMethods"-lan-m.cap" GetRPCMethods-wan.capGetRPCMethods"-wan.cap" GetRPCMethods-wan-m.capGetRPCMethods"-wan-m.cap" IOL.confIOL".conf" start.txt start-lan.cap start-lan-m.cap start-wan.cap start-wan-m.cap comments-20130410172812.bwc"comments-"20130410172812".bwc"
这似乎是制作连接字符串的第二个副本在每个附加的末尾,我无法弄清楚为什么。
非常感谢TCL提示。我在工作时只是被扔进了一个tcl项目,而我一直在自我教导自己,所以这些东西偶尔会出现。 – Joshua 2013-04-10 21:34:57