Most viewed Tcl recipes http://code.activestate.com/recipes/langs/tcl/views/2007-01-30T11:45:30-08:00ActiveState Code RecipesGenerating random intergers within a range of max & min. (Tcl)
2003-03-04T09:58:21-08:00Dom Lamhttp://code.activestate.com/recipes/users/1023440/http://code.activestate.com/recipes/186512-generating-random-intergers-within-a-range-of-max-/
<p style="color: grey">
Tcl
recipe 186512
by <a href="/recipes/users/1023440/">Dom Lam</a>
(<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/math/">math</a>).
</p>
<p>Here's an example on how to generate a random number between 2 numbers
Based on C code,
algorithm = randomNumber % ((max + 1) - min) + min
Here's the tcl version using rand():
*note
Change 100 to 1000 if you want a random number that goes into thousands. etc..
Also the rand() function generates a number between 0 & 1.
That's why one would multiply by 10 or 100 or 1000, etc..</p>
Decimal & Hex conversion routines (Tcl)
2005-06-03T11:28:27-07:00Chris Cornishhttp://code.activestate.com/recipes/users/861819/http://code.activestate.com/recipes/415982-decimal-hex-conversion-routines/
<p style="color: grey">
Tcl
recipe 415982
by <a href="/recipes/users/861819/">Chris Cornish</a>
.
</p>
<p>Here are a suite of hexadecimal to/from decimal conversion routines.
These have been used in an application, so there should not be any errors, I trust.</p>
Random number in a range (Tcl)
2001-09-10T11:25:18-07:00Jeff Hobbshttp://code.activestate.com/recipes/users/98167/http://code.activestate.com/recipes/68391-random-number-in-a-range/
<p style="color: grey">
Tcl
recipe 68391
by <a href="/recipes/users/98167/">Jeff Hobbs</a>
(<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/math/">math</a>).
</p>
<p>Tcl 8.0 added the rand() expr function. Here's a simple way to return the random number in a range.</p>
WebSphere - log WAS SESSION performance data to a cloudscape database. (Tcl)
2005-12-12T21:42:50-08:00Patrick Finneganhttp://code.activestate.com/recipes/users/1220635/http://code.activestate.com/recipes/464560-websphere-log-was-session-performance-data-to-a-cl/
<p style="color: grey">
Tcl
recipe 464560
by <a href="/recipes/users/1220635/">Patrick Finnegan</a>
(<a href="/recipes/tags/websphere/">websphere</a>).
</p>
<p>This script logs the WAS SESSION PMI performance data to a Cloudscape database.</p>
WebSphere - log WAS JDBC performance data to a cloudscape database. (Tcl)
2005-12-12T20:50:12-08:00Patrick Finneganhttp://code.activestate.com/recipes/users/1220635/http://code.activestate.com/recipes/464546-websphere-log-was-jdbc-performance-data-to-a-cloud/
<p style="color: grey">
Tcl
recipe 464546
by <a href="/recipes/users/1220635/">Patrick Finnegan</a>
(<a href="/recipes/tags/websphere/">websphere</a>).
</p>
<p>This script logs the WAS JDBC PMI performance data to a Cloudscape database.</p>
WebSphere - log WAS JVM performance data to a cloudscape database. (Tcl)
2005-12-12T21:28:02-08:00Patrick Finneganhttp://code.activestate.com/recipes/users/1220635/http://code.activestate.com/recipes/464559-websphere-log-was-jvm-performance-data-to-a-clouds/
<p style="color: grey">
Tcl
recipe 464559
by <a href="/recipes/users/1220635/">Patrick Finnegan</a>
(<a href="/recipes/tags/websphere/">websphere</a>).
</p>
<p>This script logs the WAS SESSION PMI performance data to a Cloudscape database.</p>
Bits to Hex, and back (Tcl)
2002-08-21T16:48:53-07:00andreas kuprieshttp://code.activestate.com/recipes/users/117230/http://code.activestate.com/recipes/146037-bits-to-hex-and-back/
<p style="color: grey">
Tcl
recipe 146037
by <a href="/recipes/users/117230/">andreas kupries</a>
(<a href="/recipes/tags/text/">text</a>).
</p>
<p>Code to convert a string of '0's and '1's to the corresponding hex number, and back. Note that we are _not_ talking about binary strings. Code by Jeff Hobbs, from his bag of utilities.</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>
Multi-character split (Tcl)
2001-09-10T10:07:20-07:00Jeff Hobbshttp://code.activestate.com/recipes/users/98167/http://code.activestate.com/recipes/68386-multi-character-split/
<p style="color: grey">
Tcl
recipe 68386
by <a href="/recipes/users/98167/">Jeff Hobbs</a>
(<a href="/recipes/tags/text/">text</a>).
</p>
<p>The split command splits a string based on each character that is in the splitString. This version handles the splitString as a combined string, splitting the string into constituent parts.</p>
Flexible string splitting/parsing routine (Tcl)
2005-07-06T06:44:26-07:00Joe Mistachkinhttp://code.activestate.com/recipes/users/141324/http://code.activestate.com/recipes/116653-flexible-string-splittingparsing-routine/
<p style="color: grey">
Tcl
recipe 116653
by <a href="/recipes/users/141324/">Joe Mistachkin</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 2.
</p>
<p>This routine allows you to split a string on multiple characters. Additionally, you can specify the maximum number of elements to return. The final element will contain the remainder of the string.</p>
DB2 - check tablespace status (Tcl)
2003-07-01T00:10:26-07:00Patrick Finneganhttp://code.activestate.com/recipes/users/1220635/http://code.activestate.com/recipes/208207-db2-check-tablespace-status/
<p style="color: grey">
Tcl
recipe 208207
by <a href="/recipes/users/1220635/">Patrick Finnegan</a>
(<a href="/recipes/tags/database/">database</a>).
</p>
<p>DB2 tablespaces can become unavailable for various reasons and when they do go off-line the problem may not be immediately visible. For example tablespaces in "backup pending mode" can be readable but not updateable.</p>
<p>For example:</p>
<p>------------------------------ Command Entered ------------------------------
update sch1.table1set ind = 'N' where provider = 'ABC'</p>
<hr />
<p>DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0290N Table space access is not allowed. SQLSTATE=55039</p>
<p>This looks like a permissions problem but it's actually an issue with the physical tablespace. We can enumerate the tablespace details with the "db2 list tablespaces". In this case the hex code for the "state" command indicates backup pending.</p>
<p>Table</p>
<p>Tablespace ID = 91
Name = SW380
Type = System managed space
Contents = Any data
State = 0x0020
Detailed explanation:
Backup pending</p>
<p>This procedure returns a list of tablespaces where state is abnormal.</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>
WSAdmin - Extract DataSource Properties (Tcl)
2003-12-17T23:47:37-08:00Patrick Finneganhttp://code.activestate.com/recipes/users/1220635/http://code.activestate.com/recipes/252555-wsadmin-extract-datasource-properties/
<p style="color: grey">
Tcl
recipe 252555
by <a href="/recipes/users/1220635/">Patrick Finnegan</a>
(<a href="/recipes/tags/websphere/">websphere</a>).
</p>
<p>Extract DataSource properties on WebSphere 5 server instance.</p>
<p>Windows platform.</p>
<p>Script called from top level Windows cmd file.</p>
<p>call wsadmin -f C:\scripts\websphere\JACL\extractDataSource.tcl</p>
Socket based communication (Tcl)
2001-06-21T17:02:20-07:00Jeff Hobbshttp://code.activestate.com/recipes/users/98167/http://code.activestate.com/recipes/65436-socket-based-communication/
<p style="color: grey">
Tcl
recipe 65436
by <a href="/recipes/users/98167/">Jeff Hobbs</a>
(<a href="/recipes/tags/distributed/">distributed</a>).
</p>
<p>Here we write the most simple socket based server application we
can think of. Starting from this minimal example it is very easy to
extend it to the actually wanted functionality</p>
HTTP Posting w/ File Upload (Tcl)
2002-01-24T10:55:29-08:00Jeff Hobbshttp://code.activestate.com/recipes/users/98167/http://code.activestate.com/recipes/109363-http-posting-w-file-upload/
<p style="color: grey">
Tcl
recipe 109363
by <a href="/recipes/users/98167/">Jeff Hobbs</a>
(<a href="/recipes/tags/binding/">binding</a>).
</p>
<p>The following script does general http posting and has support for uploading of files as well. It does this by sending the data as "multipart/form-data".</p>
Sending mail with attachments (Tcl)
2003-02-23T22:42:28-08:00Jeff Hobbshttp://code.activestate.com/recipes/users/98167/http://code.activestate.com/recipes/65434-sending-mail-with-attachments/
<p style="color: grey">
Tcl
recipe 65434
by <a href="/recipes/users/98167/">Jeff Hobbs</a>
(<a href="/recipes/tags/datastructures/">datastructures</a>).
Revision 2.
</p>
<p>How to send an email using the SMTP and MIME packages in tcllib (part of ActiveTcl).</p>
WebSphere - log WAS JVM performance data to a cloudscape database. (Tcl)
2005-12-12T20:14:01-08:00Patrick Finneganhttp://code.activestate.com/recipes/users/1220635/http://code.activestate.com/recipes/464545-websphere-log-was-jvm-performance-data-to-a-clouds/
<p style="color: grey">
Tcl
recipe 464545
by <a href="/recipes/users/1220635/">Patrick Finnegan</a>
(<a href="/recipes/tags/websphere/">websphere</a>).
</p>
<p>This script logs the WAS JVM PMI performance data to a Cloudscape database.</p>
Inline GIF image into code (Tcl)
2002-03-18T13:47:20-08:00Jeff Hobbshttp://code.activestate.com/recipes/users/98167/http://code.activestate.com/recipes/117247-inline-gif-image-into-code/
<p style="color: grey">
Tcl
recipe 117247
by <a href="/recipes/users/98167/">Jeff Hobbs</a>
(<a href="/recipes/tags/binding/">binding</a>).
</p>
<p>This recipe shows how to inline a GIF image directly into your Tcl code.</p>
Dump a file in hex and ASCII (Tcl)
2002-06-17T15:27:20-07:00andreas kuprieshttp://code.activestate.com/recipes/users/117230/http://code.activestate.com/recipes/133525-dump-a-file-in-hex-and-ascii/
<p style="color: grey">
Tcl
recipe 133525
by <a href="/recipes/users/117230/">andreas kupries</a>
(<a href="/recipes/tags/text/">text</a>).
</p>
<p>Origin: <a href="http://wiki.tcl.tk/1599" rel="nofollow">http://wiki.tcl.tk/1599</a>
Author: Original author unknown</p>
<p>Demonstrates the use of the [binary] and [fconfigure] commands to process a binary file.</p>
<p>The following useful Tcl script produces a hex/ASCII dump of a binary file whose name is specified on the command line.</p>
Automated Form Login (Tcl)
2003-07-29T19:32:19-07:00Patrick Finneganhttp://code.activestate.com/recipes/users/1220635/http://code.activestate.com/recipes/213028-automated-form-login/
<p style="color: grey">
Tcl
recipe 213028
by <a href="/recipes/users/1220635/">Patrick Finnegan</a>
(<a href="/recipes/tags/binding/">binding</a>).
</p>
<p>This script performs an automated form login against a site protected by the J2EE j_security_check model.</p>