Popular Tcl recipes http://code.activestate.com/recipes/langs/tcl/popular/2017-04-10T13:51:58-07:00ActiveState Code RecipesRecursive fc/diff for Windows, optionally copy missing/different files (Tcl)
2017-04-08T16:40:25-07:00John Brearleyhttp://code.activestate.com/recipes/users/4184423/http://code.activestate.com/recipes/580776-recursive-fcdiff-for-windows-optionally-copy-missi/
<p style="color: grey">
Tcl
recipe 580776
by <a href="/recipes/users/4184423/">John Brearley</a>
(<a href="/recipes/tags/compare/">compare</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/tcl/">tcl</a>).
</p>
<p>Utility to add recursive capability to fc.exe on Windows. Will optionally copy/update missing or older files as needed. If you have a diff.exe in your path, say from having installed TkDiff utility, the diff.exe will be used as the prirmary compare tool, with fc.exe as the backup tool.</p>
diff_copy.tcl Utility for daily differential backups of large windows directory structures (Tcl)
2017-04-10T13:51:58-07:00John Brearleyhttp://code.activestate.com/recipes/users/4184423/http://code.activestate.com/recipes/580779-diff_copytcl-utility-for-daily-differential-backup/
<p style="color: grey">
Tcl
recipe 580779
by <a href="/recipes/users/4184423/">John Brearley</a>
(<a href="/recipes/tags/backup/">backup</a>, <a href="/recipes/tags/daily/">daily</a>, <a href="/recipes/tags/tcl/">tcl</a>).
</p>
<p>When you have terrabytes of data with 100,000+ files, it is no longer practical to blindly copy the entire data structure on a daily basis. I wrote this utility diff_copy.tcl to sort out what has been changed/updated and what new files have been added and only copy the changed & new items. If the date/time of the source file is newer, the file will be copied. If the date/time of the source file is the same as the destination, the file sizes in bytes are checked to decide if a copy is necessary. If the source file is not present on the destination directory, the file is copied. There are options to remove old files from the destination directory or show what would be copied, but not actually do the copy.</p>
A Simple Calculator (Tcl)
2014-09-06T13:36:35-07:00Mike Manilonehttp://code.activestate.com/recipes/users/4190728/http://code.activestate.com/recipes/578929-a-simple-calculator/
<p style="color: grey">
Tcl
recipe 578929
by <a href="/recipes/users/4190728/">Mike Manilone</a>
(<a href="/recipes/tags/calculator/">calculator</a>, <a href="/recipes/tags/gui/">gui</a>).
</p>
<p>A simple calculator. Calculation is done by [expr].</p>
Stopwatch in 26 lines (Tcl)
2014-09-05T13:33:13-07:00Mike Manilonehttp://code.activestate.com/recipes/users/4190728/http://code.activestate.com/recipes/578927-stopwatch-in-26-lines/
<p style="color: grey">
Tcl
recipe 578927
by <a href="/recipes/users/4190728/">Mike Manilone</a>
(<a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/time/">time</a>).
</p>
<p>This stopwatch works on Tcl/Tk 8.5 and higher. It makes use of the [clock] command and reduced the amount of code by -textvariable. A simple one, indeed. Nevertheless, it is still easy-to-read and easy-to-understand and it does show the power that Tcl has.</p>
Track Debug Package argument(s) are option(s) and/or a debug message to be saved to a file (Tcl)
2014-03-23T22:31:40-07:00Bert Byfieldhttp://code.activestate.com/recipes/users/4188497/http://code.activestate.com/recipes/578855-track-debug-package-arguments-are-options-andor-a-/
<p style="color: grey">
Tcl
recipe 578855
by <a href="/recipes/users/4188497/">Bert Byfield</a>
(<a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/pdisplay/">pdisplay</a>, <a href="/recipes/tags/ptrack/">ptrack</a>, <a href="/recipes/tags/trace/">trace</a>, <a href="/recipes/tags/track/">track</a>, <a href="/recipes/tags/tracklst/">tracklst</a>).
</p>
<h4 id="package-require-tracks">package require tracks</h4>
<h4 id="ptrack-on-off-clear-overflow-overflowgo-abend-104-message-text">pTrack ?-on? ?-off? ?-clear? ?-overflow? ?-overflowGo? ?-abend? ?"104 message text"?</h4>
<p>A user-specified text message is written to a file "tracklst.txt" in the same directory as the source program. Tracking can be turned on or off, and the clear option sets the file to zero bytes. The program defaults to raise an error if the tracklst.txt file gets too big (default is one megabyte), but the overflowGo option will cause it to just turn off tracking and continue. The abend option will raise an optional error. The message is whatever the user wants it to be, but suggested usage is to always start with three digits that identify a proc and a fourth alphabetic character that marks the track uniquely and allows searching for a specific track. Also includes pDisplay, which writes a debug message to a tk_messageBox dialog window.</p>
<p>e.g.: pTrack -clear "Start a new test by emptying the track file" <br>
pTrack "140d date adjusted to $tMon of $tYear"
pTrack "135b Current working directory is [pwd]"</p>
Poker hand calculation and comparison (Tcl)
2013-06-24T05:03:10-07:00Magnus Åhmanhttp://code.activestate.com/recipes/users/4180631/http://code.activestate.com/recipes/578539-poker-hand-calculation-and-comparison/
<p style="color: grey">
Tcl
recipe 578539
by <a href="/recipes/users/4180631/">Magnus Åhman</a>
(<a href="/recipes/tags/poker/">poker</a>).
Revision 2.
</p>
<p>Calculates 1. the category of the hand (high card, one pair, etc...) and 2. the "kicker" values that act as tiebreakers to (possibly) distinguish two hands of the same category from each other. These two attributes, category and kickers, are then used by the cmp method to compare two hand objects and return -1, 0 or 1.</p>
Sample script for TCL socket load distribution across many CPUs / hosts (Tcl)
2012-11-29T17:27:20-08:00John Brearleyhttp://code.activestate.com/recipes/users/4184423/http://code.activestate.com/recipes/578351-sample-script-for-tcl-socket-load-distribution-acr/
<p style="color: grey">
Tcl
recipe 578351
by <a href="/recipes/users/4184423/">John Brearley</a>
(<a href="/recipes/tags/distribution/">distribution</a>, <a href="/recipes/tags/load/">load</a>, <a href="/recipes/tags/socket/">socket</a>, <a href="/recipes/tags/tcl/">tcl</a>).
</p>
<p>Here is a demo script for others to reuse / learn from. The server process hands out work assignments to multiple children process to do load balancing across multiple CPUs / hosts. The children process in this sample script dont do any real work, but occasionally create an error to demonstrate the error handling and recovery. Enjoy!</p>
Basic Text Editor (Tcl)
2011-03-21T23:10:10-07:00Jonathan Fenechhttp://code.activestate.com/recipes/users/4169413/http://code.activestate.com/recipes/577617-basic-text-editor/
<p style="color: grey">
Tcl
recipe 577617
by <a href="/recipes/users/4169413/">Jonathan Fenech</a>
(<a href="/recipes/tags/basic/">basic</a>, <a href="/recipes/tags/editor/">editor</a>, <a href="/recipes/tags/text/">text</a>).
</p>
<p>Text editor with copy,cut and paste functions.</p>
Spawn command not found error (Tcl)
2010-09-24T16:07:59-07:00siva prasadhttp://code.activestate.com/recipes/users/4175066/http://code.activestate.com/recipes/577408-spawn-command-not-found-error/
<p style="color: grey">
Tcl
recipe 577408
by <a href="/recipes/users/4175066/">siva prasad</a>
.
</p>
<p>Installed ActiveTCL and executed the commands "teacup install --force Expect".</p>
<p>I executed a script which will telnet to given ip.The following is the error.</p>
<p>The system cannot find the file specified.
while executing
"spawn telnet $Machine".</p>
<p>let me know,anything missed ?</p>
<p>Thanks,
Siva.</p>
iTunes control (Tcl)
2010-03-30T04:06:56-07:00Frank Bannonhttp://code.activestate.com/recipes/users/4167503/http://code.activestate.com/recipes/577165-itunes-control/
<p style="color: grey">
Tcl
recipe 577165
by <a href="/recipes/users/4167503/">Frank Bannon</a>
(<a href="/recipes/tags/itunes/">itunes</a>, <a href="/recipes/tags/tcom/">tcom</a>).
</p>
<p>Simple TCL commands can control your iTunes player, add network control, or create an alternate interface. This recipe uses the tcom package on Windows.</p>
Parse a DIS PDU (Tcl)
2009-08-29T09:49:16-07:00Frank Bannonhttp://code.activestate.com/recipes/users/4167503/http://code.activestate.com/recipes/576892-parse-a-dis-pdu/
<p style="color: grey">
Tcl
recipe 576892
by <a href="/recipes/users/4167503/">Frank Bannon</a>
(<a href="/recipes/tags/dis/">dis</a>, <a href="/recipes/tags/pdu/">pdu</a>, <a href="/recipes/tags/udp/">udp</a>).
</p>
<p>Decodes Distributed Interactive Simulation (DIS) Protocol Data Units (PDUs) from UDP packets.
Requires UDP package (<a href="http://tcludp.sourceforge.net%29" rel="nofollow">http://tcludp.sourceforge.net)</a></p>
<p>Entity State (1), Fire (2), and Detonation (3) PDUs are decoded.</p>
Distributed Interactive Simulation (Tcl)
2012-06-15T00:14:10-07:00Frank Bannonhttp://code.activestate.com/recipes/users/4167503/http://code.activestate.com/recipes/576568-distributed-interactive-simulation/
<p style="color: grey">
Tcl
recipe 576568
by <a href="/recipes/users/4167503/">Frank Bannon</a>
(<a href="/recipes/tags/dis/">dis</a>, <a href="/recipes/tags/pdu/">pdu</a>, <a href="/recipes/tags/udp/">udp</a>).
Revision 2.
</p>
<p>Decode Distributed Interactive Simulation (DIS) Protocol Data Units (PDUs) captured from UDP packets.
PDUs decoded: Entity State, Fire, Detonation, Transmitter, Signal.
Captures a packet from UDP, then decodes the data and adds it to a log.</p>
Pronouncable password generator (Tcl)
2008-02-03T15:35:46-08:00Rob Haeuslerhttp://code.activestate.com/recipes/users/4119868/http://code.activestate.com/recipes/544293-pronouncable-password-generator/
<p style="color: grey">
Tcl
recipe 544293
by <a href="/recipes/users/4119868/">Rob Haeusler</a>
.
</p>
<p>I wanted a GUI pronouncable password generator that was not Internet based, that would meet the password rules required by the various systems that I work with. I've used a basic python program (non-GUI) modified to tcl/tk.</p>
Script checking availability of network servers (Tcl)
2007-08-27T23:57:08-07:00Alex Khokhlovhttp://code.activestate.com/recipes/users/4078056/http://code.activestate.com/recipes/528899-script-checking-availability-of-network-servers/
<p style="color: grey">
Tcl
recipe 528899
by <a href="/recipes/users/4078056/">Alex Khokhlov</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
Revision 2.
</p>
<p>Script checking availability of network servers
If the server is not accessible, starts action
The necessary data are read from a text file</p>
<p>The file of the data contains lines of a kind:</p>
<p>smtp_server:25:any_executed_program:my_smtp_server
httpd_daemon:80:ps:corp_web_server</p>
what words and phrases phone number spells (Tcl)
2007-08-10T10:11:54-07:00Slava Lysunkinhttp://code.activestate.com/recipes/users/4074276/http://code.activestate.com/recipes/528866-what-words-and-phrases-phone-number-spells/
<p style="color: grey">
Tcl
recipe 528866
by <a href="/recipes/users/4074276/">Slava Lysunkin</a>
.
</p>
<p>This simple TCL script can generate all possible variants of pnone number spells using numbers and letters</p>
Minor enhancement to the base Tk Console. Additional change. (Tcl)
2007-08-24T01:29:47-07:00Mike Collinshttp://code.activestate.com/recipes/users/1127585/http://code.activestate.com/recipes/523001-minor-enhancement-to-the-base-tk-console-additiona/
<p style="color: grey">
Tcl
recipe 523001
by <a href="/recipes/users/1127585/">Mike Collins</a>
.
Revision 2.
</p>
<p>Right click Copy and Paste.
And when you source a script from the command line, you lose the focus, and have to click the mouse button somewhere in the console screen to be able to type again.
Fixed that around line # 616. Inserted "focus $w" and now it works better.</p>
Connect to Oracle DB. (Tcl)
2007-01-30T11:45:30-08:00Patrick Finneganhttp://code.activestate.com/recipes/users/475144/http://code.activestate.com/recipes/502195-connect-to-oracle-db/
<p style="color: grey">
Tcl
recipe 502195
by <a href="/recipes/users/475144/">Patrick Finnegan</a>
(<a href="/recipes/tags/tclblend/">tclblend</a>).
</p>
<p>Quick connection to Oracle Database.</p>
dumpThreads (Tcl)
2007-02-05T18:24:13-08:00Patrick Finneganhttp://code.activestate.com/recipes/users/475144/http://code.activestate.com/recipes/502208-dumpthreads/
<p style="color: grey">
Tcl
recipe 502208
by <a href="/recipes/users/475144/">Patrick Finnegan</a>
(<a href="/recipes/tags/websphere/">websphere</a>).
Revision 2.
</p>
<p>Take a java core dump from a running server. Identify the working directory where the file will be placed.</p>
Create Properties Object. Return loaded property object. (Tcl)
2007-01-31T10:22:15-08:00Patrick Finneganhttp://code.activestate.com/recipes/users/475144/http://code.activestate.com/recipes/502196-create-properties-object-return-loaded-property-ob/
<p style="color: grey">
Tcl
recipe 502196
by <a href="/recipes/users/475144/">Patrick Finnegan</a>
(<a href="/recipes/tags/tclblend/">tclblend</a>).
</p>
<p>Uses the java Properties class to read a java formatted property file. Returns a loaded Property object. Access the properties using the get property method.</p>
<p>$PropertyI getProperty SSLConfig.name</p>
Scripted Telnet Client Class (Tcl)
2006-09-12T21:13:56-07:00Flavio Salgueirohttp://code.activestate.com/recipes/users/2418930/http://code.activestate.com/recipes/496990-scripted-telnet-client-class/
<p style="color: grey">
Tcl
recipe 496990
by <a href="/recipes/users/2418930/">Flavio Salgueiro</a>
(<a href="/recipes/tags/network/">network</a>).
Revision 2.
</p>
<p>A simlpe Telnet Client Class utilizing Todd Martin's telnet package available at <a href="http://www.tmartin.org/tcltelnet" rel="nofollow">http://www.tmartin.org/tcltelnet</a> .</p>