我想将telnet控制台日志重定向到linux中的文件.
例如:
telnet $someIp > someFile
#ls
#exit
Run Code Online (Sandbox Code Playgroud)
我希望控制台日志保存在文件名"someFile"中.我用它tcl来自动化这个.截至目前,我做spawn telnet $someIp在tcl.
这不会捕获控制台日志并将其保存到文件中.
可以这样做吗?
我有一个名为“startMyProc {num}”的过程。我希望这个 proc 被两个不同的线程调用并等待两个线程完成。我尝试了给出的有效解决方案。我想访问 startMyProc 中的全局变量并调用另一个过程“startMyAnotherProc {num}”。如何才能做到这一点?
package require Thread
global myVar
set myVar false
set id1 [thread::create -joinable {
source sample.tcl
thread::wait
}]
set id2 [thread::create -joinable {
source sample.tcl
thread::wait
}]
set num 1
thread::send -async $id1 [list startMyProc $num]
set num 2
thread::send -async $id2 [list startMyProc $num]
thread::join $id1
thread::join $id2
My sample.tcl looks like this,
proc startMyProc { num } {
global myVar
puts $myVar
puts "Opening $num"
after 2000
puts "Opening $num"
after 2000 …Run Code Online (Sandbox Code Playgroud)