我正在使用putty连接服务器并执行命令,但我不知道如何将命令输出重定向到文本小部件。
exec patchtoputty/putty.exe -ssh myserver -pw mypass -m mycommand
通常这应该(?)有效:
catch {exec patchtoputty/putty.exe -ssh myserver -pw mypass -m mycommand} results
.text insert 1.0 $results
但不是在这种情况下我正在执行具有自己的终端窗口的putty(或例如cygwin)命令。
此致 卢卡斯
答案 0 :(得分:2)
抓取窗口的输出并将其插入文本小部件非常棘手;你必须经常抓住屏幕并OCR结果或其他东西。可笑了。
但是对于腻子,你最好的选择是从同一个家庭切换到plink.exe(=“Putty LINK”)。它基本上是腻子但没有窗口的东西,并且能够在管道中很好地运行。它采用与putty相同的选项,因此修改代码应该非常简单。
catch {exec wherever/plink.exe -ssh myserver -pw mypass -m mycommand} results
.text insert 1.0 $results
(建立自己的腻子?只要确保你同时建立plink。)