tcl

how to escape unusual/uniq characters from expect scripts?

心已入冬 提交于 2021-02-16 20:14:28
问题 in expect script I can set any command or character to run it on remote machine but the sad thing is that expect cant send the same character as they defined in the expect script for example I want to run this line from expect script in order to change IP address from 10.10.10.10 to 1.1.1.1 expect # {send "perl -i -pe 's/\Q10.10.10.10\E/1.1.1.1/' /etc/hosts\r"} but when I run the expect screen actually I see this line runing on the console: [root@localhost ~]# perl -i -pe 's/Q10.10.10.10E/1.1

TCL - Parse JSON to hash/array

帅比萌擦擦* 提交于 2021-02-16 15:36:06
问题 I'm new in TCL, I have an JSON string, and I want to parse it to something I can use it easily like hash/ array which similar like in Perl or Java to loop the data and print it. But I've found many sources to help me, but it is very less and still couldn't get it. And I try something like this: #!/usr/bin/tclsh proc dict2json {dictVal} { # XXX: Currently this API isn't symmetrical, as to create proper # XXX: JSON text requires type knowledge of the input data set json "" dict for {key val}

Capture stdout within a TCL catch command

杀马特。学长 韩版系。学妹 提交于 2021-02-16 14:44:28
问题 In my main tcl script, I am calling a tcl proc wrapped in a catch command. This proc in-turn calls 10 more procs. When there is an error in execution in any of those 10 procs, TCL still continues execution of my main script as expected and I am just able to view the error message which I captured. This error message may/may-not be conclusive enough to determine which of the 10 procs errored out during execution. Is there a way to still keep capturing all the stdout until the point of error? I

Comparing two lists and returning the difference

丶灬走出姿态 提交于 2021-02-15 07:44:57
问题 I've got two lists of lists, I match them and print any differences. The two lists are cable connections within a FPGA station. I need to ensure: All the connections on the $list1 exist on $list2 , if not, it should save the error on another list All the connections on $list2 exist on $list1 , so I don't get any 'wrong' connections. Any connections that don't exist on either list should be saved onto another variable. The lists are in this format: {{A.B2} {B.B3}} and the the $list2 equivalent

Comparing two lists and returning the difference

我只是一个虾纸丫 提交于 2021-02-15 07:43:43
问题 I've got two lists of lists, I match them and print any differences. The two lists are cable connections within a FPGA station. I need to ensure: All the connections on the $list1 exist on $list2 , if not, it should save the error on another list All the connections on $list2 exist on $list1 , so I don't get any 'wrong' connections. Any connections that don't exist on either list should be saved onto another variable. The lists are in this format: {{A.B2} {B.B3}} and the the $list2 equivalent

Triggering an error on unsetting a traced variable

天大地大妈咪最大 提交于 2021-02-11 15:33:18
问题 I'm trying to create some read-only variables to use with code evaluated in a safe interp. Using trace , I can generate an error on attempts to set them, but not when using unset : % set foo bar bar % trace add variable foo {unset write} {apply {{var _ op} { error "$var $op trace triggered" }}} % set foo bar can't set "foo": foo write trace triggered % unset foo % Indeed, I eventually noticed the documentation even says in passing: Any errors in unset traces are ignored. Playing around with

List passed to join doesn't produce the correct output

半城伤御伤魂 提交于 2021-02-11 14:57:39
问题 I collect some information using the following method: proc getJobinfo {question} { puts -nonewline "$question: " flush stdout gets stdin answer set cleanedanswer [string trim [::textutil::string::capEachWord $answer]] if {$cleanedanswer eq ""} { throw {Value Empty} {Input cannot be empty!} } return $cleanedanswer } and capture the result like this: set systemTime [clock seconds] set yearmonthday [clock format $systemTime -format %Y%m%d-%H%M%S] set company_name [getJobinfo "Company Name"] set

Tkinter, canvas, create_text and zooming

*爱你&永不变心* 提交于 2021-02-11 13:19:13
问题 Is it normal that Tkinter's Canvas' create_text 's font size doesn't change when I change the Canvas' scale with canvas.scale ? I thought that, as it is a high level GUI management system, I wouldn't have to resize manually the text done with create_text after a zooming. Isn't this strange, or am I wrong ? 回答1: It's normal, even if not entirely what you want. The scale method just changes the coordinate lists, but text items only have one of those so they just get (optionally) translated.

parsing text file in tcl and creating dictionary of key value pair where values are in list format

女生的网名这么多〃 提交于 2021-02-10 12:16:35
问题 How to seperate following text file and Keep only require data for corresponding : for example text file have Format: Name Roll_number Subject Experiment_name Marks Result Joy 23 Science Exp related to magnet 45 pass Adi 12 Science Exp electronics 48 pass kumar 18 Maths prime numbers 49 pass Piya 19 Maths number roots 47 pass Ron 28 Maths decimal numbers 12 fail after parsing above Information and storing in dictionary where key is subject(unique) and values corresponding to subject is list

parsing text file in tcl and creating dictionary of key value pair where values are in list format

一个人想着一个人 提交于 2021-02-10 12:16:16
问题 How to seperate following text file and Keep only require data for corresponding : for example text file have Format: Name Roll_number Subject Experiment_name Marks Result Joy 23 Science Exp related to magnet 45 pass Adi 12 Science Exp electronics 48 pass kumar 18 Maths prime numbers 49 pass Piya 19 Maths number roots 47 pass Ron 28 Maths decimal numbers 12 fail after parsing above Information and storing in dictionary where key is subject(unique) and values corresponding to subject is list