【发布时间】:2019-06-28 20:44:04
【问题描述】:
set pipeline [open "|Certify.exe args" "r"]
fconfigure $pipeline -blocking false
fconfigure $pipeline -buffering none
fileevent $pipeline readable [list handlePipeReadable $pipeline]
proc handlePipeReadable {pipe} {
if {[gets $pipe line] >= 0} {
# Managed to actually read a line; stored in $line now
} elseif {[eof $pipe]} {
# Pipeline was closed; get exit code, etc.
if {[catch {close $pipe} msg opt]} {
set exitinfo [dict get $opt -errorcode]
} else {
# Successful termination
set exitinfo ""
}
# Stop the waiting in [vwait], below
set ::donepipe $pipe
} else {
puts ""
# Partial read; things will be properly buffered up for now...
}
}
vwait ::donepipe
我曾尝试在 TCL 代码中使用管道。但出于某种原因,我想将其转换为 Spawn-Expect 机制。但我正在努力解决它并在这样做时面临问题。谁能帮帮我?
【问题讨论】:
-
什么问题?显示您的期望代码。
-
spawn "Certify.exe $parameters(0) $parameters(1) $parameters(2) $parameters(3) $parameters(4) $parameters(5) $parameters(6) $parameters (7) $parameters(8) $parameters(9) $parameters(10) $parameters(11) $parameters(12) $parameters(13) $parameters(14) $parameters(15)"
-
使用 spawn 后,在关闭和打开应用程序实例时,加载 Java VM 时出现错误
-
我也没有使用过期望,因为我现在没有在这种情况下如何使用期望