小编Sar*_*ran的帖子

如何将telnet控制台日志重定向到文件linux

我想将telnet控制台日志重定向到linux中的文件.

例如:

telnet $someIp > someFile
#ls
#exit
Run Code Online (Sandbox Code Playgroud)

我希望控制台日志保存在文件名"someFile"中.我用它tcl来自动化这个.截至目前,我做spawn telnet $someIptcl.

这不会捕获控制台日志并将其保存到文件中.

可以这样做吗?

linux shell tcl

2
推荐指数
2
解决办法
1万
查看次数

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)

multithreading tcl

2
推荐指数
1
解决办法
2198
查看次数

标签 统计

tcl ×2

linux ×1

multithreading ×1

shell ×1