FAQ Database Discussion Community


apply regsub for certain line in a paragraph in tcl

tcl
This is the group of lines in which I have assigned to test variable set test {tkt(pnr( ticket(20140414,130559), fbcode(y), etkt(yes), entry(price), trap([flist,186,tkt1,bag],[start(1)]), city(y) ])).} I need to search some list of values from "trapremlist" variable inside "trap([flist,186,tkt1,bag]". set trapremlist {bag bagdisclosure bt} If any value from trapremlist is there in...

Increasing numbers in strings by python or Tcl

python,arrays,string,integer,tcl
I have some strings with integer numbers (From 2 to 5 numbers in one string, separated by spaces) this is an example: 1 4 5 19 1 5 2 3 6 59 2 6 3 2 4 60 3 4 4 1 3 61 4 3 25 13 23 64...

Bash - Hiding a command but not its output

bash,tcl,expect
I have a bash script (this_script.sh) that invokes multiple instances of another TCL script. set -m for vars in $( cat vars.txt ); do exec tclsh8.5 the_script.tcl "$vars" & done while [ 1 ]; do fg 2> /dev/null; [ $? == 1 ] && break; done The multi threading portion...

Returning Some Variable from a “proc” in Tcl

tcl
Suppose that a procedure in Tcl is as follows: proc Section {ID x y} { . . "Some calculations do here" . . } Section 1 20 30 Section 2 25 35 Section 3 30 40 Section 4 35 45 Now, I define this: set IDsection {1 3} Then, I...

Pick out certain lines from files

list,testing,tcl
I am writing a tcl script that reads from a file and displays certain lines from this file. I can read from the file n problem but I cant figure out how to pick out certain lines BEFORE filtering out what I don't need. I am reading the file to...

Loading tcl extension from tclsh

tcl,tclsh
I have a C extension to Tcl where command mytest is defined. The extension is compiled correctly (I am on Linux, extension is *.so). For example, I can start tclsh and use it like this: $ tclsh % load /path/extension.so % mytest abc ... But, if I create a file...

Tcl/Tk: horizontal xscrollbar can not shrink as y scollbar

scrollbar,tcl,tk
In the following example code: proc push_button {} { set name [.ent get] .txt insert end "Hello, $name." } frame .frm -relief groove label .lab -text "Enter name:" entry .ent button .but -text "Push Me" -command "push_button" frame .textarea text .txt -width 20 -height 10 \ -yscrollcommand ".srl_y set" -xscrollcommand...

No Such Variable When Using While Loop in Expect

tcl,expect
I'm attempting to access a variable within a while loop in expect, but I keep getting an error that the variable doesn't exist. The code in question: #!/usr/bin/expect spawn ./simulator.sh set timeout 1 ...<extra code>... # Return the time in seconds from epoch proc getTime {year month day hour minute}...

Float Number mathematical operation

math,floating-point,tcl
I have a .txt file as output from a program that contains some values of interest. The problem is that in certain cases these values have a strange format and i'm not able to apply mathematical operations on them. E.g: My file contains these numbers: -2.55622-3 -0.31-2 -3.225-2 ... These...

How to store a line from expect_out(buffer) to a variable in tcl

bash,foreach,tcl,expect
For example, if the output ( in expect_out(buffer) )is blah blh blah asdjsudfsdf how can I store the 2nd line to a variable? so far I have this: foreach line [split $expect_out(buffer) "\n"] { if [lindex $line 1] { set variable $line } } But this does not work, it...

TCL get array value using variable as key name

tcl
I have the following array list that contains IANA Cipher Suites IDs (Key Name) with their corresponding names (Values) array set IANA_Ciphers [list {0000} {"TLS_NULL_WITH_NULL_NULL"} \ {0001} {"TLS_RSA_WITH_NULL_MD5"} \ {0002} {"TLS_RSA_WITH_NULL_SHA"} \ {0003} {"TLS_RSA_EXPORT_WITH_RC4_40_MD5"} \ [...] {C0AF} {"TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8"} ] Now I need to be able to access this array's values...

Tcl crange vs. string range

string,tcl
Why does the Tcl wiki say to consider string range over crange? I know that crange is TclX and string range is not, but are there any other differences? And if not, then why does crange exist?

Using [clock format] through TKinter changes how proc returns “”

python,tkinter,type-conversion,tcl
I am using TKinter to access an existing Tcl library from Python. One of the Tcl procs looks up values in a list and returns "" if the value is not found. The Python code sees the return value as unicode and checks to see if it is equal to...

tcl tdom parsing failed due to special charecters in xml tags

xml,tcl,tdom
I am trying to remove some special characters which was existed in XML tags, we can use some regsubs or string map function to eliminate XML special chars in tagged text, But It is lengthy/time consuming process because our log file was very huge around ~25 MB. Is there any...

Tcl return vs. last evaluated in proc - internals

return,tcl,proc
When I write a proc in Tcl, which return value is actually the result of another proc I can do either of the following (see implicit example): proc foo args { ... ... bar $var1 } Or I could do (see explicit example): proc foo args { ... ... return...

How can I check if a directory is empty?

tcl,expect
I'm aware that expect is tcl-in-sheep's-clothing, but even when I google with that in mind I'm coming up empty. Is there a way to determine if a particular directory is empty (or not empty, I can just use negation)?...

How to get selective data from a file in TCL?

tcl,tk
I am trying to parse selective data from a file based on certain key words using tcl,for example I have a file like this ... ... .. ... data_start 30 abc1 xyz 90 abc2 xyz 214 abc3 xyz data_end ... ... ... How do I catch only the 30, 90...

When Tcl library package is loaded?

tcl
When you create new interpreter it already contains Tcl package in it. Does somebody knows when this package is loaded? Is there any startup scripts that are calling package ifneeded Tcl {....} ?

tablelist label color while mouse hovers

user-interface,tcl,tk
I've configured the background color of some lables of my tablelist by using the columnconfigure $ColumnIndex -labelbgmethod. However, the background color changes while the mouse hovers over the labels. I couldn't find any -activebackground method and I wish the background color will stay the same even when the mouse hovers...

Get items in specific index list of lists

list,tcl
I have a key-value list such as: set x {{a 1} {b 2} {c 3}} I need to extract all the items in index=1 in all sub-lists to get: {1 2 3} ...

Search for element after a designated string

tcl
I have a script that reads from a file and sorts out certain lines by a keyword. I need to be able to pick out a certain element from each of these discovered lines. The lines in the file are set up lie; $(eval $(call CreateUvmTest, keyword, element_needed, morestuff... $(eval...

How to check with tcl if MySQL Server online

mysql,tcl
I have a Tcl Script that connects to a mysql DB running on a other server. Now the script terminates if i reboot the other server. Is there a way of checking if the server or better the mysql service is running, before connecting? Thanks in advance...

How to search a a directory tree in TCL for files that end in .so or .a and build a list of those directories

tcl
I'm trying to write a set of TCL scripts that helps setup a user's environment for a set of libraries that are not in their standard LD_LIBRARY_PATH as part of a support solution. Since the system is rather sparse in terms of what I can install, I don't really have...

Tcl script breaks out of foreach loop

foreach,nested,tcl,expect
I have a tcl script to log into devices and print SUCCESS. This is the script: The file: (the first IP is valid, and can be logged into, the next 3 are fake). 192.38.133.145 178.18.34.48 183.24.56.3 145.234.67.145 The script: #!/bin/expect package require Expect set file [open "hosts" r] set f_data...

expect fails when running proc inside proc

bash,unix,tcl,expect
My script works fine (retrieves sftp prompt) when using one proc. But when I try to use proc inside proc, script gets stuck, and I do not know why. Please do not refactor the code, that is not the point, I need to understand what is the issue here. Working...

Ns2 nodes do not make concurrent http requests

if-statement,for-loop,tcl,ns2
I wrote an ns2 script to run concurrent HTTP requests from 40 nodes out of 80 nodes. However, the simulation showed one node, rather than 40 nodes, make requests to the HTTP server. Could someone please clarify what might be wrong with the code? The code is provided below Thank...

Generate random number within specified range without REDUNDANCY in TCL

random,tcl,ns2
hi I need to generate 30 random numbers without any repeatations of numbers in TCL. Here is the code to generate random number which works fine, but will generate redundant numbers. proc myRand { min max } { set maxFactor [expr [expr $max + 1] - $min] set value [expr...

Strange behavior of tcl comments?

comments,tcl
I have the following tcl file: proc test {} { ## proc test {} { # puts "test" ## } puts "Hallo" } Which does not produce an error. If I now delete the closing braced in the comment I get an error proc test {} { ## proc test...

Why isn't exception handling built into the “dict get” command?

tcl
When dictionaries were first implemented and added to Tcl, why was the dict get command implemented in a way that allows an error to occur if an attempt is made to retrieve a value for a key that is not present in the dictionary? This requires you to wrap the...

tcl non curly braces expression slower than with them?

performance,if-statement,tcl
I have noticed something. Let's look at two codes bit. in 1, if is not input with a curly brace input, the other is. The curly braced 1 is slightly faster. Why? See codes and outputs below: puts [ time { if { [ expr { 5 % 2 }...

Cannot evaluating variable within IF and For loop using TCL

tcl
In following code in TCL I cannot seem evaluate the variable "a" I'm evaluating x and y, in the same For Loop I have a IF statement that is checking for a range between x and y. If valid then I'd like to perform some more calculations within the IF...

Search two patterns in one line in tcl using regex

regex,tcl
I have a string as follows: o=India-SIPUA 6264 0 IN IP4 10.77.33.200 Now I need to write a code to check whether the string "o=India-SIPUA" as well as the string 10.77.33.200 are present in the above string or not. I wrote the following code: [regexp {.*o=India-SIPUA.*10.77.34.200} $buf match], but it's...

split and assign into scalar variables in TCL

split,tcl
I have a variable and I want to split and assign the chunks to scalar variables. Example: Variable = vdd_not_gated#7#T I want to assign: net = VDD_NET1 Layer = 7 border = T I tried following Code in TCL : set variable vdd_not_gated#7#T set fields [split $variable #] foreach field...

TCL access array by reference/name

arrays,reference,tcl
Let's say I have a regular variable that contains the name of an existing array. array set myarr { key_1 val_2 key_2 val_2 } set myvar myarr I can found nowhere how I can iterate over myarr from myvar!...

Append a string to variable during array creation

arrays,tcl
I'm attempting to create a very simple array in TCL but I can't figure out the syntax to make it append text to a variable in an assignment. Here is what I am trying to do: set var1 "some text" set var2 "other text" array set arrValues { 1 $var1...

Non-Greedy regex acts greedy based on the position of atoms in regex

regex,tcl,non-greedy
I came across one situation where I wanted to use non-greedy atom .*? in the regex pattern. set input "Device ID: HOST1 Interface: GigabitEthernet0/1, Port ID (outgoing port): GigabitEthernet2/43 Device ID: HOST2 Entry address(es): Interface: GigabitEthernet0/2, Port ID (outgoing port): GigabitEthernet2/43 " puts "======== Non-Greedy regex starting with some other...

Tcl How to write data to a specific line number in the middle of operating

numbers,tcl,output,line,puts
Is there any way or command in Tcl for writing in the middle of {data.txt} and also specific line number ... ? for example after writing data in text file, when I'm writing in line number 1000, is there any way for turning back to line number 20 and adding...

Tcl procedure return vs. set as return operator

function,tcl,return-value
Let us say that I have a procedure, and I wish to return a value of a variable local to the procedure. There are many ways to do that, but 2 very simple ones, are, at the very last line of the procedure puts either of these command (assume that...

Please help me with the simple tcl code

linux,tcl
It is a simple code which gives the output when a number is raised to another number.But it is always returning the square of the number and not looping. Please help guys #!/usr/bin/tclsh proc raise {{base} {pow} args} { for {set base1 $base} {$pow >= 0} {incr $pow -1} {...

Executing a test in TCL

tcl
I am pretty new with TCL but I am writing a script that will search a file for testcases and filter out ones with specific key words and run these test using exec. It runs the first test fine but once it completes it begins to run the same test...

Error: clock scan “-100000 minutes” -base 1

tcl
I just stumbled upon this legacy code, which uses the deprecated clock FreeScan: clock scan "-100000 minutes" -base 1 which leads to an error. However, clock scan "-99999 minutes" -base 1 seems to work. I would be interested in the reason for this limit, or is this a bug?...

How to deploy complex tcl applications

deployment,tcl
How to deploy complex tcl applications and where to find a good getting started with a minimal example? I want to deploy the application in form of a tcl interpeter with the application tcl packages included. Preferable as one binary....

Replace several lines of commands with a single variable in tcl

tcl,tk
I know I have been asking a lot of questions but I'm still learning tcl and I haven't found anything that similar to this issue anywhere so far. Is it at all possible to replace a set f commands in tcl with one variable function0 for example? I want to...

Grepping second pattern after matching first pattern

regex,perl,sed,grep,tcl
Is there any grep/sed option which will allow me to match a pattern after matching another pattern? For example: Input file (foos are variable patterns starting with 0 mixed with random numbers preceded by # in front): 0foo1 0foo2 0foo3 \#89888 0foo4 0foo5 \#98980 0foo6 So once I try to...

FIFO file in TCL

tcl,hang,fifo,mkfifo,gunzip
I need to unzip file in a named pipe return it: proc unzip_file_if_needed { fileName } { if { [file extension $fileName] != ".gz" } { return $fileName; } set tmpDir [fileutil::tempdir] set tmpFileName [ file join $tmpDir [ pid ] ] if { [file exists $tmpFileName ] } {...

Setting array value as a list

tcl
I am having trouble with this snippet of code: set rect(1) [list 0 0 $x1 $y1] set rect(2) [list $x1 0 $x2 $y1] set rect(3) [list $x2 0 $x3 $y1] set rect(4) [list 0 $y1 $x1 $y2] set rect(5) [list $x1 $y1 $x2 $y2] set rect(6) [list $x2 $y1 $x3...

Getting uniqe elements of the list in the following pattern

sorting,tcl
I am trying to get lsort command with following behaviour,Lets say i have a variable & set variable {a a a a b b b b c c c c } desired output is a b c d if variable is set variable { b b d d c c...

Expect, find files with timestamp

tcl,expect
I have folder with files as below: RBS_delete20150518-170641.xml RBS_delete20150517-160545.xml ... I'm using expect program, but can't get regexp working on date stamp: if {[file exists /home/ARNE/ARNE/SCRIPTS/RBS_delete[0-9].xml]} ...

How can I find out if a Tcl_Obj is a certain kind of ttk:: entity, such as ttk:entry?

c++,tcl,tk
I am working with a legacy (Desktop-style, as they're now known) Windows application built mostly in C and C++. When this application is running on a touchscreen Windows laptop, I need to automatically show the touch keyboard when the user taps inside an entry box on a dialog screen. This...

Putting a string on same line tcl

bash,tcl
I have a nmap output and I need to put strings on different lines on same line. Nmap Output: Nmap scan report for 169.254.0.1 Host is up (0.014s latency). Not shown: 97 closed ports PORT STATE SERVICE 80/tcp open http 1720/tcp open H.323/Q.931 5060/tcp open sip Device type: VoIP adapter|WAP|PBX|webcam|printer...

How do I print more than one value per key in Tcl?

arrays,tcl
array set array_in_twos { set1 table set2 chair set1 chair } foreach combo [array names array_in_twos] { puts "$combo is $array_in_twos($combo)," } outputs: set1 is chair, set2 is chair, It seems the second 'set 1' replaces the first 'set 1'. how do i print all? set1 is table, set2 is...

real-time TCL exec output

tcl,try-catch,exec
I have the following scenario: if { [catch { exec echo calling a BIG script } exec_msg] } { puts "NOK" puts "output of the BIG script: $exec_msg" } else { puts "OK" puts "output of the BIG script: $exec_msg" } Are there any solutions to print the $exec_msg in...

Running multiple exec commands and waiting to finish before continuing

background,tcl,exec,tk
I know I ask a lot of questions and I know there is a lot on here about this exactly what I am trying to do but I have not been able to get it to work in my script nor figure out why it does not let me do...

Expand passed arguments before printing with puts to virtual server

shell,tcl,expect
I am having trouble with an expect script not evaluating arguments. Everything in the puts ${file_id} block (simplified obviously) gets placed onto a virtual machine and is later used to for configuration. The block you see puts the same code into a local directory for me to see if things...

Itcl What is the read property?

properties,tcl,itcl
I want to control read access to an Itcl public variable. I can do this for write access using something such as: package require Itcl itcl::class base_model_lib { public variable filename "" } itcl::configbody base_model_lib::filename { puts "in filename write" dict set d_model filename $filename } The configbody defines what...

EXPECT SCRIPT:procedure being ran before actual code

stored-procedures,tcl,expect,procedure
I'm creating an expect script to let me use macros in my managing of cisco devices. after all the connections are done, my script waits for the "#" so I know the user is ready for input. if I define my procedure AFTER interact, script works fine, but obviously it...

Deleting duplicate lines along with original

perl,awk,sed,grep,tcl
I have a file which contains patterns on each line, some of which are repeating. i want only those patterns which do not repeat. So, I want to remove all repeating data along with the original pattern. I cannot use sort since i want the patterns to be in same...

TK/TCL, trouble understanding this tic tac toe code snippet

tcl,tk
Can anyone help explain to me what the snippet below does. This code snippet is taken from http://wiki.tcl.tk/12374. It is meant to create a tic tac toe game. There are not many resources out there for understanding Tk/Tcl so this is giving me significant difficulty. proc DrawBoard {{redraw 0}} {...

Having issue with back reference in TCL

regex,tcl,regexp-replace,regexp-substr
I have the following code: set a "10.20.30.40" regsub -all {.([0-9]+).([0-9]+).} $a {\2 \1} b I am trying to grep 2nd and 3rd octet of the IP address. Expected output: 20 30 Actual output: 20 04 0 What is my mistake here?...

tcl script error on ns2 (no such variable)

tcl,ns2
I tried to run the example code available here: http://simula.stanford.edu/~alizade/Site/DCTCP_files/dctcp-ns2-rev1.0.tar.gz As per the readme file, the patch was successfully applied but on executing the example code, the following error was obtained: ns: myTrace file3: can't read "dctcp_alpha_": no such variable while executing "subst $[subst $var]" (procedure "_o154" line 5) (Object...

TCl-Tk How to catch floating point numbers from a file

file,floating-point,tcl,tk
i'm finding some troubles working on a file containing some floating numbers. These are some rows from my file: 174259 1.264944 -.194235 4.1509e-5 174260 1.264287 -.191802 3.9e-2 174261 1.266468 -.190813 3.9899e-2 174262 1.267116 -.193e-3 4.2452e-2 What i'm trying to do is to find the row where is my desire number...

Using a tcl proc to login to devices

tcl,expect,session-timeout
I have a tcl (expect) script to log into devices and transfer files. Unfortunately, the files are large, and during the transfer period the ssh connection ends (the files are still transferred though). So I basically have to login again before I can perform more actions on the device. Since...

if all else fails tcl script fails

tcl,expect,scp
I am trying to make a script to transfer file to another device. Since I cannot account for every error that may occur, I am trying to make an if-all-else fails situation: spawn scp filename [email protected]:filename expect "word:" send "password" expect { "100" { puts "success" } "\*" { puts...

Questions on Regex algorithm (not necessarily EXPECT related)

regex,tcl,expect
I'm trying to create a regex to capture the neighbor detail of my devices (example output below). I could hard code each individual line, but I'm looking for a better solution. maybe learn a new algorithm. I'm interested in capturing Device ID (HOST1), Interface (GigabitEthernet0/1), and Port ID (GigabitEthernet2/43). for...

tk entry background color change in readonly mode

tcl,tk,entry
Hi I have a requirement where i need to create table and the cells would be readonly. But along with readonly mode, the cells need to have colored background. Now with the given options, i tried doing something like below but with no luck. Since I am learning GUI designing,...

Quickest way to evaluate a variable in TCL

reference,tcl,expect,evaluation
I have a variable myref set to: set myref {$expect_out(buffer)} What is the quickest way to get the $expect_out(buffer) into myval? set myval [HOWTOEVAL $myref] ...

Tcl: Producing a Loop (*)

tcl
I want to produce a loop in Tcl that if n=2 creates: set Beam_Gravity_Load [subst {$a $b}] if n=3: set Beam_Gravity_Load [subst {$a $a $b}] if n=4: set Beam_Gravity_Load [subst {$a $a $a $b}] if n=5: set Beam_Gravity_Load [subst {$a $a $a $a $b}] and so on. "n" always is...

TCL parsing a list of arguments to an external call

python,python-3.x,tcl
Im trying to execute a call to a python script through aldec riviera-pro my call is python $python_app_name $python_app_args However my $python_app_args are passed as a single string and not multiple strings resulting in that the python application only sees it as one argument and its execution fails. I've tried...

How to find corresponding values in columns using TCL

tcl
I'm a regular matlab user who needs to do some processing in TCL. I have no experience with tcl so up to now what I have done is by searching on google. Please pardon novice ways... I have data in column A and B which is imported via file Data_1,...

Bug or feature? Missing closing quote in Tcl is rarely seen as syntactically incorrect.

tcl
I tried it with Tcl 8.3 and 8.5: The statement puts X" is syntactically correct and outputs just an X and a double quote. I would have expected, that Tcl complains about a missing closing quote. OTOH, if I enter the statements puts "X and puts " in a tclsh,...

regsub/regex parsing on list of elements in tcl

tcl
I need to convert a string with list with more than one elements (<>,abcd1,1,1) as like below. From: test={abc([(<>,yifow3,1,1),(abc,yifow3,2,2,20140920,20151021),(<>,yifow3,3,3,20140920,20151021),(<>,yifow3,4,4)])} To: abc([(yifow3,1,1),(yifow3,2,2),(yifow3,3,3),(yifow3,4,4)]) I tried to extract the list inside abc([]) using the below regsub. always it will have "abc([" at the begining and "])" at the end. regsub -all {(abc\(\[)([a-z0-9\<\>\(\),]+)(\)\])} $test...

Convert expect output from DOS to UNIX style in realtime

tcl,expect,dos2unix
I write some expect scripts by connecting to a remote host through serial connection. My problem is that the output of the spawned process (enabled with log_user 1) contains DOS-style endings (each line being terminated with ^M when reading logs in VIM). I normally run dos2unix on all logs at...

TCL: Make code cleaner from nested if-statements

if-statement,tcl
This is a procedure of one of the items of the status bar on i3 window manager on linux. Is run every second. Basically deals with frequency governors. If temperature reaches a certain number then switch to powersave mode, or if a certain application is running, e.g. steam, or the...

How can I search for a file using tcl, with only part of the file name

regex,bash,foreach,tcl,ls
If I have a folder with the following files: hello-version-1-090.txt hello-awesome-well-091.txt goodday-087.txt hellooo-874.txt hello_476.txt hello_094.txt How can I search for a file which has the term: 'hello' and '091' in it using tcl. Possible solution: taking the output of an ls -l in a folder, splitting it with '\n' and...

For loop increment by a non-integer in TCL

tcl
I want to implement the following C code in TCL: Float power_pitch = 8 float offset = 7.5 float threshold = 100 for(i=power_pitch+offset ; i<= threshold ; i += power_pitch) I want to implement above forloop in TCL. I have tried the following code in TCL: set power_pitch 8 set...

Change only a part of text file using AWK in TCL

awk,tcl,ns2
I want to change only particular value of text file using AWK and retain rest of the values as it is. The input file, ene.txt: energy_of_node 1 48.03004556 energy_of_node 2 56.05655687 energy_of_node 3 48.03004556 energy_of_node 4 56.05655687 energy_of_node 5 48.03004556 energy_of_node 6 56.05655687 energy_of_node 7 48.03004556 energy_of_node 8 56.05655687 I...

Google Analytics for TCL-TK

google-analytics,tcl,tk
Is there any code for using Google Analytics on a TCL-Tk program? I've tried to implement it "handmade" using a webserver, and sending messages via TclWs but I'm sure that Google Analytics can be a better (or best) solution for this problem....

getting values in R from tkentry() widgets

r,user-controls,widget,tcl,tk
I'm trying to create a small interactive window in which user (for now me) can enter specific information regarding power calculations (test name, number of groups, type of data) in order to perform the correct kind of power calculation. I know how to do this directly in R, but I...

How to get repeated number in string? [closed]

regex,tcl
i want to get number of times particular number repeated in a string? Consider number is 2 , if 22 available in sting means , we should not consider as repeated number. set a "1232163122631261112312" in that 2 is repeated 5 times (we should not take 22 as 2 times...

How to execute 'Zoom Fit' in ModelSim/QuestaSim from TCL console?

tcl,vhdl,simulator,modelsim
I'm using ModelSim / Questa-SIM from command line in GUI mode. If ModelSim runs in GUI mode I would like to execute a 'Zoom Fit' from my imported 'wave.do' file. I pass this file to vsim by -do wave.do. Here is the script: add wave * run -all I started...

How to combine two arrays for form two column data using TCL

arrays,tcl
I have another question, how would I combine two arrays to form two columns. I've seen a zip command e.g. set n $a.zip(b) puts $output $n However when I save the file it is all in a single line. Kindly advice....

cannot curl from tcl (eggdrop bot) after restart freebsd/freenas-jail

curl,cron,tcl,eggdrop
I am running a freenas jail environment that run a few eggdrop scripts. One of the scripts at some point executes the command (in tcl): set nfoc [exec curl -m 10 -s -f -k -3 --connect-timeout 3 -L "$url" -o "/tmp/$filename"] So it downloads a file. All was working well...

tkinter TclError: can't find package treectrl

python-3.x,tkinter,tcl,tk,python-module
Just installed tktreectrl as shown in this tutorial: https://www.youtube.com/watch?v=ddpYVA-7wq4 but when i try to run my program i'm getting this error. Traceback (most recent call last): File "E:/Python/Competition/Competition.py", line 36, in <module> listbox = TkTreectrl.MultiListbox(window) File "E:\Programs\Python\lib\site-packages\TkTreectrl\MultiListbox.py",line 50, in __init__ Treectrl.__init__(self, master, showroot=showroot, **kw) File "E:\Programs\Python\lib\site-packages\TkTreectrl\Treectrl.py", line 489, in __init__...

Cisco Show command filtering

tcl,command-line-interface,show,cisco,cisco-ios
I am writing a script to capture certain lines of config from a cisco device. Unfortunately the buffer keeps getting filled up. So I was wondering if cisco devices can have 2 include statements. For example: show start | include vpn && protocol The 2 lines that I need info...

What is a good approach for continuous searching for a fresh term of a pattern in a large file?

tcl
The AUT creates logs for a particular function run and appends the log in a central file. The line to search in this file is: LatestTimeStamp>MyFunction SomeStep timeLapsed SOME_TIME_VALUE Every time the log is generated by AUT, fresh multiple logs of similar pattern are generated as above and its required...

Segmentation fault with expect 5.43.0 with tclsh 8.4

ubuntu,tcl,expect
I am currently using expect 5.43.0 along with tclsh 8.4. When i include the expect package i get segmentation fault. my script contains #!/usr/bin/tclsh package require Itcl package require Expect How to fix this problem. Any suggestions will be helpful Regards...

Tcl Regexp confusion

regex,tcl
I have the following code in a tcl script $a_list - {Hello1.my.name.is.not.adam.go.away, Hello2.my.name.is.not.adam, Hello3.my.name.is.not.adam.leave.me} foreach a $a_list {if {[regexp adam [regsub {.*\.} $a {}]] == 1} {puts $a} } My understanding is that this looks for the string adam in $a_list and it matches when adam is the last string....

Running multiple instances of one tcl script

multithreading,bash,tcl,expect,multiple-instances
Currently I am reading in host names from a file using a foreach command and using this hostname to connect to the device. All this is done within my TCL script. Is there a way I can run multiple instances of the script so that each device is queried separately?...

TCL, get full error message in catch command

error-handling,tcl
#!/usr/bin/tclsh proc test {} { aaa } test When I run this script I get error message: invalid command name "aaa" while executing "aaa" (procedure "test" line 2) invoked from within "test" (file "./a.tcl" line 7) If I run test command in catch I get only first line of error...

Line break support in parser (TCL)

parsing,tcl
So, I have a parser, written in TCL. There are many commands in the parsing file. Now, I need to add support for line breaks. For ex. my_command \ arg1 \ arg2 \ arg3 I have something like this. while { ! [eof $currentFileDescriptor] } { set line [gets $currentFileDescriptor]...

ns: 217: invalid command name “217” while executing “217”

tcl,ns2
I am simulating Wireless Sensor Network using NS2.35 and I get an error saying ns: 217: invalid command name "217" while executing "217" I have no where used such command throughput my tcl file. Can any one help why I get this error? ...

How to catch subst exceptions in TCL

exception,tcl,subst
Here is a code example: set my_ref {$undefined_array(some_key)} set my_val [subst $my_ref] which returns: can't read "undefined_array(some_key)": no such variable while executing "subst $my_ref" According to http://wiki.tcl.tk/1501 Looks like there is no way to catch this right now ...

TCL hang on gets

c,tcl,io-redirection
I have a parent C process that creates a child tcl process and re-directs the stdin/stdout of the child to interact with the parent. It seems to work correctly but there is a part where the child never receives what the parent is receiving. If any one can spot the...

How to match a colon after a close bracket

tcl,expect
Why does the following not match the : expect { timeout {puts timedout\n} \[1\]: {puts matched\n} } > expect test.tcl [1]: timedout If I change it and remove the colon the match works: expect { timeout {puts timedout\n} \[1\] {puts matched\n} } $ expect test.tcl [1] matched Or if I...

Pass variable as parameter to awk file in TCL

variables,awk,parameters,tcl
I want to pass variable to awk file in TCL which is somewhat similar to below code. Is there any way? // out.tr is input file and variable to be passed is to_node my_code.tcl: set to_node 13 exec awk -f check_ack.awk out.tr $to_node check_ack.awk: BEGIN {} { # variable passed...

Tcl - passing curly braces into a variable within a regsub command

tcl
I need to pass a regular expression as a variable within a regsub command. I want to eliminate the brackets from cap variable, but I am unable to pass the curly braces within the match variable. set cap {[equality choice control]} set match {\[} regsub -all $match $cap "" cap...

tcl tcltest unknown option -run

testing,tcl
When I run ANY test I get the same message. Here is an example test: package require tcltest namespace import -force ::tcltest::* test foo-1.1 {save 1 in variable name foo} {} { set foo 1 } {1} I get the following output: WARNING: unknown option -run: should be one of...

What is the purpose of packages “provide” and “ifneeded” command in TCL?

package,tcl
I Want to know , What is the purpose of packages "provide" and "if-needed" commands in TCL ? Please any body clarify my doubts. Thanks in Advance. ...

What is wrong with this example in TCL book

tcl
I am reading "Tcl/Tk: A developer's guide", in chapter 3.1, it has such bad example: if {$x > 2} { set greater true } The book says this code is wrong syntax because "No space between test and body left brace" and will get error message: Error Message: invalid command...

Using $variable in Parenthesis in Tcl (proc)

tcl
A part of my code in tcl is: proc Frame {columnLine} { . . . } Now I want use $variable in parenthesis. For example: set x 2. set columnLine {$x 5. 10. 15.} However, after running Tcl, I face an error! How I do solve this problem?...