- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
过去几天我一直在寻找问题的解决方案,所以最后我来到了这里。
我必须编写一个应该从 Linux/Debian 系统打开的 Tcl 脚本。问题是,该脚本应该登录到 Cisco 路由器,然后进入特殊的 tclsh 模式,在该模式下它应该获取代表 txload 的 SNMP 值。过了一会儿,我在 tclsh 模式(支持 SNMP)下获得了该值,但我无法将其返回到我的脚本中。它仍然仅存在于路由器 tclsh 模式下。我的脚本应该根据 tclsh 中已有的值更改一些其他值,但不再需要 tclsh。
所以这是我的问题:如何从 tclsh 获取 $ifnum
值,但我仍然可以在该脚本中使用某些循环,因为我需要在 $ifnum
将作为条件的情况下进行一些循环?
如您所见,脚本尚未完成,但正如我所说,我被困在这里并试图弄清楚:
#!/usr/bin/expect -f
set gateway [lindex $argv 0]
set serial [lindex $argv 1]
set timeout 5
spawn telnet $gateway
expect "Password:"
send "cisco\r"
expect "*>"
send "en\r"
expect "Password:"
send "cisco\r"
expect "*#"
send "set ifnumstr \[snmp_getone odczyt 1.3.6.1.4.1.9.2.2.1.1.24.6\]\r"
expect "*}"
send "regexp \{val='(\[0-9\]*)'\} \$ifnumstr \{\} ifnum \r"
expect "*#"
send "puts \$ifnum \r"
expect "*#"
最佳答案
我会让它打印出您在标记之间查找的内容,然后在其 RE 匹配模式中使用 expect
来获取该值。
send "puts \"if\\>\$ifnum<if\"\r"
expect -re {if>(.*?)<if}
# Save the value in a variable in the *local* script, not the remote one
set ifnum $expect_out(1,string)
关于linux - Tcl 期望从 tclsh 输出到 shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28158873/
由于各种平台(Linux、SUN)中 tclsh 的不同路径,任何人都知道如何在 Tcl 代码中调用 tclsh? 例如在 SUN 中: #!/usr/bin/sun/tclsh 在 Linux 中:
我正在使用 Ubuntu 18.04.1 LTS,内核 4.15.0-34-generic。我是一个相当新的用户,在为我的新项目安装了一堆软件(不幸的是,我已经忘记了)时,每次打开终端时我突然出现这两
从我的 Tcl 脚本中,我想找到运行我的脚本的 tclsh 可执行文件的路径(如 Python 中的 sys.executable),或者至少找到如何从命令行调用 tclsh(如 Perl 中的 $^
我正在尝试在 Windows 7 上构建一个名为 Slicer3 的软件,该软件具有“ super 构建”功能。这是一个用于检查和构建 Slicer3 的一体化 TCL 脚本。 我运行 CYGWIN
tclsh 有内联命令之类的东西吗? 比如:tclsh -e "set a 7 ; puts $a" 当然我试过上面的方法,还是不行。但是你明白了吗? 谢谢,格特 最佳答案 使用 Expect,您可以
我搜索了很长时间,但只能找到一个简短的解释,即 $@ 扩展了一些东西。 有人可以解释一下或向我提供一个链接,以详细解释 "$@" 作为 的第二个参数的目的 tclsh "$0" "$@" 另外,我正在
我正在尝试在 Windows 7 上构建一个名为 Slicer3 的软件,该软件具有“ super 构建”功能。这是一个用于检查和构建 Slicer3 的一体化 TCL 脚本。 我运行 CYGWIN
tclsh 有内联命令之类的东西吗? 比如:tclsh -e "set a 7 ; puts $a" 当然我试过上面的方法,还是不行。但是你明白了吗? 谢谢,格特 最佳答案 使用 Expect,您可以
我想将我的 tclsh 从/import/vne/bin/tclsh 更改为/import/desapps/tcl/bin/tclsh。我在做 export PATH=$PATH:/import/de
我刚刚在我的 Ubuntu 12.04.3 64 位上安装了 Tcl/Tk 8.5.11。我安装了以下两个命令: %sudo apt-get install tcl %sudo apt-get ins
在csh你可以做 set ignoreeof 或者在 bash tou 上可以做 export ignoreeof=1 这将使 csh/bash 忽略 EOF,即它不会在 Ctrl+D 时退出,或者当
我正在尝试使用用 C++ 编写的包(共享库)运行 tclsh。该包需要一种类似于 Windows PumpMessage 的机制,以便在通过包 req 加载后在主线程上定期调用。 有了愿望,我可以简单
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
可以在 TCL shell (tclsh) 中使用光标键(如向上箭头键)获取命令历史记录。 我在 fedora 上运行 tclsh,linux 版本为 2.6.21。 最佳答案 您想访问 readli
我有一个 tclsh 脚本,我需要在其中在后台执行某些命令。我可以使用 exec 命令从 tcl 实现这一点:exec myprog &。 但是我如何等待 myprog 从 tcl 完成。命令 wai
我是一个业余爱好者,尝试拼凑一个小项目。这是一个简单的笔记存储和检索控制台应用程序,适用于 Windows Vista(和 XP - 我希望通过 USB 内存棒运行整个程序)。 我使用 Sqlite
我已经看过理论并理解为什么第一个比第二个快的解释,但我想看看 tcl 中的字节码。在 python shell 中,很容易看到字节码,但我很难找到在 tclsh 中查看它的解决方案。 #first a
我有一个具有多次出现模式的字符串。我需要从字符串中提取第一个模式。 即: 我的模式: ABC : 1 XXX : 3 YYY : 4 ZZZ : 9 ABC : 3 XXX : 4 YYY : 6 Z
过去几天我一直在寻找问题的解决方案,所以最后我来到了这里。 我必须编写一个应该从 Linux/Debian 系统打开的 Tcl 脚本。问题是,该脚本应该登录到 Cisco 路由器,然后进入特殊的 tc
为什么我不能使用向左和向右箭头键(实际上,向上和向下键也是如此)在 tclsh 中我当前所在的行上移动。交互式 shell ?如果我尝试按任何一个,我会得到一堆 abracadabra 而不是来回移动
我是一名优秀的程序员,十分优秀!