tcl

How to get a reference on the Itcl class member variable?

浪尽此生 提交于 2020-02-07 03:16:06
问题 Say I have the following structure: package require Itcl itcl::class AAA { private variable m_list {} constructor {} { fill m_list list } } How to get a reference on the m_list in order to write foreach elem $reference {.......} Consider that list is really big and I don't want to copy it! 回答1: Tcl variables use copy-on-write semantics. You can safely pass a value around, assigning multiple variables to it, without worrying about it taking up more space in memory. For example set x {some list

Making decisions on expect return

喜你入骨 提交于 2020-02-06 11:13:59
问题 I am trying to create an expect script which will send a different password string based on the "expect" Condition A: If a cisco device has not been setup with a username then the first prompt will simply be "Password:" - then it should use passwordA (no username) Condition B: If it has been setup with a username then the prompt will be "Username:" followed by "Password:" - then it should use Username and PasswordB #!/bin/bash # Declare host variable as the input variable host=$1  # Start the

Making decisions on expect return

核能气质少年 提交于 2020-02-06 11:12:20
问题 I am trying to create an expect script which will send a different password string based on the "expect" Condition A: If a cisco device has not been setup with a username then the first prompt will simply be "Password:" - then it should use passwordA (no username) Condition B: If it has been setup with a username then the prompt will be "Username:" followed by "Password:" - then it should use Username and PasswordB #!/bin/bash # Declare host variable as the input variable host=$1  # Start the

Making decisions on expect return

吃可爱长大的小学妹 提交于 2020-02-06 11:12:10
问题 I am trying to create an expect script which will send a different password string based on the "expect" Condition A: If a cisco device has not been setup with a username then the first prompt will simply be "Password:" - then it should use passwordA (no username) Condition B: If it has been setup with a username then the prompt will be "Username:" followed by "Password:" - then it should use Username and PasswordB #!/bin/bash # Declare host variable as the input variable host=$1  # Start the

Tcl/Tk write in a specific line

孤街浪徒 提交于 2020-02-02 10:07:09
问题 I want to write in a specific line in Textdocument but there´s a Problem with my code, i don´t know where the bug is. set fp [open C:/Users/user/Desktop/tst/settings.txt w] set count 0 while {[gets $fp line]!=-1} { incr count if {$count==28} { break } } puts $fp "TEST" close $fp The File only contains TEST. Has anybody an idea? 回答1: You are using 'w' as access argument, which truncates the file. So you will loose all data from file while opening. Read more about open command You can use 'r+'

TCL电视无法装apk文件

╄→尐↘猪︶ㄣ 提交于 2020-01-27 03:31:48
TCL电视使用U盘装apk文件时显示“没有可播放的文件” 步骤: 1.应用里面找到电视卫视 2.应用管理 3.极速安装 4.打开U盘安装应用 来源: CSDN 作者: canaryW 链接: https://blog.csdn.net/cobracanary/article/details/103994389

two level splatter TCL

半世苍凉 提交于 2020-01-25 19:01:05
问题 If I have a procedure or a command in TCL, with variable number of arguments, one can use, if a list's elements are as an input, the "splatter" operator, for example: set a [list "ko" ] set m [ list "ok" "bang" ] lappend a {*}$m But, what if I want to "twice splatter"? I.e., flatten 2 levels? Using it twice, in sequence, does not work: set a [list "ko" ] set m [ list [ list "ok" ] [ list "bang" ] ] lappend a {*}{*}$m Will error out on extra character. 回答1: You've noticed that {*}

Tcl Expect fails spawning SSH to server but SSH from command line works

夙愿已清 提交于 2020-01-25 12:12:10
问题 I have some code that I'm using to connect to a server and perform some commands. The code is as follows: #!/usr/bin/expect log_file ./log_std.log proc setPassword {oldPass newPass} { send -- "passwd\r" expect "* Old password:" send -- "$oldPass\r" expect "* New password:" send -- "$newPass\r" expect "* new password again:" send -- "$newPass\r" } set server [lindex $argv 0] spawn /bin/ssh perfgen@$server # Increase buffer size to support large text responses match_max 100000 # Conditionally

Tcl Expect fails spawning SSH to server but SSH from command line works

﹥>﹥吖頭↗ 提交于 2020-01-25 12:11:46
问题 I have some code that I'm using to connect to a server and perform some commands. The code is as follows: #!/usr/bin/expect log_file ./log_std.log proc setPassword {oldPass newPass} { send -- "passwd\r" expect "* Old password:" send -- "$oldPass\r" expect "* New password:" send -- "$newPass\r" expect "* new password again:" send -- "$newPass\r" } set server [lindex $argv 0] spawn /bin/ssh perfgen@$server # Increase buffer size to support large text responses match_max 100000 # Conditionally

How to do lappend in a while loop using regexp

天大地大妈咪最大 提交于 2020-01-25 03:09:18
问题 when I am using the while loop to match a variable using regexp I want the matched variable to form a list by using lappend. The code is set file_name [open filename.txt r] set newlist [list] while {[gets $file_name line] >= 0} { regexp {cell \(\"(.*)\"} $line match cell_name if {[info exists cell_name] && $cell_name != ""} { puts "$cell_name" lappend $newlist $cell_name unset cell_name } } foreach item $newlist {puts $item} close $file_name The text which it is matching is like cell ("aabbcc