tcl

No glob expansion without -re option in Expect

南楼画角 提交于 2020-01-15 10:45:37
问题 #!/usr/bin/expect spawn passwd [lindex $argv 0] set password [lindex $argv 1] expect -nocase "pass*" { send "$password\r" } expect -nocase "password" { send "$password\r" } expect eof How can I prevent expect to expand the glob * in pass* ? This is just an example. In my actual code, I want to keep the glob, but I don't want to at -ex , which stands for exact match, or -re option for regex. 回答1: If you want a glob-style match, use the -gl option before it: expect { -gl -nocase "pass*" { # Do

No glob expansion without -re option in Expect

寵の児 提交于 2020-01-15 10:44:05
问题 #!/usr/bin/expect spawn passwd [lindex $argv 0] set password [lindex $argv 1] expect -nocase "pass*" { send "$password\r" } expect -nocase "password" { send "$password\r" } expect eof How can I prevent expect to expand the glob * in pass* ? This is just an example. In my actual code, I want to keep the glob, but I don't want to at -ex , which stands for exact match, or -re option for regex. 回答1: If you want a glob-style match, use the -gl option before it: expect { -gl -nocase "pass*" { # Do

How to copy or move multiple files with same extension?

你离开我真会死。 提交于 2020-01-15 09:18:07
问题 So I am trying to move a bunch of files with similar extensions from /home/ to /root/ Code I tried is file copy /home/*.abc.xyz /root/ Also tried set infile [glob -nocomplain /home/*.abc.xyz ] if { [llength $infile] > 0 } { file copy $infile /root/ } No success. 回答1: Your two attempts fail for different reasons: There is no wildcard expansion in arguments to file copy , or any Tcl command, for that matter: file copy /home/*.abc.xyz /root/ . This will look for a single source with a literal *

Install Tkinter without root access

纵然是瞬间 提交于 2020-01-15 08:43:07
问题 I'm having a bit of trouble trying to install Tkinter on a Linux system without having root privileges. According to the second answer to this question: Install tkinter for Python there is a way, and it involves downloading the source of Tkinter and TCL and then running their install routines in custon directories created one level below the home directory. I did that and everything except for the last step where it says run setup.py build and setup.py install. I can't find these files

Will Tcl Interp created in separate threads share any global data?

半城伤御伤魂 提交于 2020-01-14 14:36:48
问题 In my C++ code, if I create one tcl interp per thread, and use it to Tcl_EvalEx a script, and get result by Tcl_GetStringResult, is this thread safe? There's no shared data between these threads except const data. After some searching on google I found this in the tcl threading model doc: http://www.tcl.tk/doc/howto/thread_model.html Tcl lets you have one or more Tcl interpreters (e.g., created with Tcl_CreateInterp()) in each operating system thread. However, each interpreter is tightly

How to store output in a variable while using expect 'send' command

时间秒杀一切 提交于 2020-01-14 07:43:08
问题 Thanks. But the account and password are needed. So I must send them and then send ovs-vsctl command. the scripts are something like this: spawn telnet@ip expect -re "*login*" { send "root" } expect -re "password*" { send "****" } send "ovs-vsctl *******" I want to store the output of this command send "ovs-vsctl ****" , but many times I got some output of the command "send "password"", how can I get the output of send "ovs-vsctl****" . The output of the command send "ovs-vsctl *** are two

TCL, How to name a variable that includes another variable

谁说胖子不能爱 提交于 2020-01-14 05:25:11
问题 In TCL, I'm writing a procedure that returns the depth of a clock. But since I have several clocks I want to name the var: depth_$clk proc find_depth {} { foreach clk $clocks { … set depth_$clk $max_depth echo $depth_$clk } } But I get: Error: can't read "depth_": no such variable Use error_info for more info. (CMD-013) 回答1: Your problem is this line: echo $depth_$clk The issue is that the syntax for $ only parses a limited set of characters afterwards for being part of the variable name; the

Pass bash array to expect script

烈酒焚心 提交于 2020-01-14 03:42:07
问题 I have a bash script that calls an expect script like so $SCRIPTS_DIRECTORY/my_expect_script.sh $my_bash_array I can pass a variable over, it seems, and use it. For this example the variable seems to be in [lindex $argv 0] . From bash, it will be a bunch of values, e.g. 1 2 3 4 5 . I am trying to figure out how to use expect to grab this variable, save it to an array then loop through the array to spit out multiple commands one at a time. So my output should be something like send command 1

How do I link the ActiveState distribution of Tcl/Tk to HomeBrew installed Python

时光毁灭记忆、已成空白 提交于 2020-01-13 07:33:31
问题 I am using macOS 10.12.1 Sierra. I am using Python 2.7.12 installed with brew install python but the IDLE gives the warning WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information. and sure enough, it crashed frequently. 8.5.9 is the macOS preinstalled version. I can download the stable 8.5.18 from the ActiveState website (as recommend by python, which works with the python installations from python.org (as they

Tcl介绍

杀马特。学长 韩版系。学妹 提交于 2020-01-12 23:01:09
Tcl(Tool command language) 是一个基于字符串的命令语言,基础结构和语法非常简单,易于学习和掌握。 基本语法: command args1 args2 . . . 每条命令第一项为命令名,后面为相应参数,注意所有标点符号都必须使用英文符号 命令行终止可以由回车新起一行或末尾加分号(;)来判定 当命令太长,一行写不下来的时候,可以在句末加反斜杠(),则下一行的文本依然属于本行命令 set list1 'a b c\ d e f' 即a b c d e f 3.注释使用#开头,#需要位于句首 4.方括号([ ])用来嵌套执行其他命令行 来源: CSDN 作者: 丿孙小飞 链接: https://blog.csdn.net/qq_43670393/article/details/103949444