【发布时间】:2015-07-20 09:50:44
【问题描述】:
我想将变量传递给 TCL 中的 awk 文件,这有点类似于下面的代码。有什么办法吗? // out.tr 是输入文件,要传递的变量是 to_node my_code.tcl:
set to_node 13
exec awk -f check_ack.awk out.tr $to_node
check_ack.awk:
BEGIN {}
{
# variable passed should be saved in node[i] --> But this doesnot work
for ( i = 0; i < ARGC; i++ ) {
node[i] = ARGV[i]
}
status = $7
if(FILENAME=="trace.tr") {
if(node[1] > -1 && $1 == "s" node[1] == $3 && status == "ack") {
print "Node" " "node[1]" " "has not sent acknowledgement" > "failed.txt"
}
}
}
END {
exit 0
}
【问题讨论】:
-
这真的只是一个awk问题; Tcl 完全按照要求发送值……
-
是的。这纯粹与 awk 相关,而 awk 并不能识别传递的变量。
标签: variables awk parameters tcl