本文介绍了特写括号后TCL多余字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个错误Tcl错误:收盘后,括号多余的字符
PROC确切{缺口主机手柄通道文字} {
全球db_handle网络;集大小EXEC卷曲-3 --ftp SSL的FTP -k:// XXX:[email protected]:2300 /源/ | grep的\\\\河| AWK'{打印$ 5}'| AWK'{SUM + = $ 1} END {打印SUM / 1024/1024}putnowPRIVMSG #chnnel:源有$大小
}
解决方案
%的的需要用花括号来代替单引号。您还需要 []
围绕 EXEC
来调用它:
集大小[EXEC卷曲-s -3 --ftp的SSL -k {FTP:// XXX:[email protected]:2300 /源/} | grep的\\\\河| AWK {{打印$ 5}} | AWK {{SUM + = $ 1} END {打印SUM / 1024/1024}}]
这是说,你不需要调用的grep
或 AWK
可言。一切你跟他们在这里做可以Tcl的code内完成:
PROC确切{缺口主机手柄通道文字} {
全球db_handle网络; 设置状态0
设置错误[{抓
集RESP [EXEC卷曲-s -3 --ftp的SSL -k {FTP:// XXX:[email protected]:2300 /源/}]
}结果的选项]
如果{$错误} {
设置细节[字典得到$选项 - 错误code]
如果{[LINDEX $细节0] EQCHILDSTATUS} {
设置状态[LINDEX $详细2]
putnowPRIVMSG $声道:卷曲的错误$状态
}
}
集大小0
的foreach线[分裂$ RESP \\ n] {
如果{[字符串匹配{* \\\\。R *} $行]} {
增量大小[LINDEX $线4]
}
} putnowPRIVMSG $通道:源有[EXPR {$大小/ 1024/1024}]
}
(我假设你的意思 $通道
,而不是 #chnnel
)
i have this error Tcl error : extra characters after close-brace
proc exact {nick host handle channel text} {
global db_handle network;
set size exec curl -3 --ftp-ssl -k ftp://xxx:[email protected]:2300/source/ | grep \\.r | awk '{print $5}'| awk '{ SUM += $1} END { print SUM/1024/1024 }'
putnow "PRIVMSG #chnnel :source has $size"
}
解决方案
Per the exec(n) man page you need to replace single quotes with curly braces. You also need []
around exec
to invoke it:
set size [exec curl -s -3 --ftp-ssl -k {ftp://xxx:[email protected]:2300/source/} | grep \\.r | awk {{print $5}} | awk {{ SUM += $1} END { print SUM/1024/1024 }}]
That said, you don't need to invoke grep
or awk
at all. Everything you do with them here can be accomplished within the Tcl code:
proc exact {nick host handle channel text} {
global db_handle network;
set status 0
set error [catch {
set resp [exec curl -s -3 --ftp-ssl -k {ftp://xxx:[email protected]:2300/source/}]
} results options]
if {$error} {
set details [dict get $options -errorcode]
if {[lindex $details 0] eq "CHILDSTATUS"} {
set status [lindex $details 2]
putnow "PRIVMSG $channel :curl error $status"
}
}
set size 0
foreach line [split $resp \n] {
if {[string match {*\\.r*} $line]} {
incr size [lindex $line 4]
}
}
putnow "PRIVMSG $channel :source has [expr {$size/1024/1024}]"
}
(I assume you've meant $channel
rather than #chnnel
.)
这篇关于特写括号后TCL多余字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!