Version 10 of ctcl

Updated 2011-04-17 10:21:43 by APN

ctcl is basically a tclkitsh or tclsh replacement for Windows. It is a console application with twapi bound in. Binary download from [L1 ]

The biggest difference though from tclsh or tclkitsh is in its accepting scripts from the command line using standard Tcl syntax and some extensions that make interactive use convenient. Examples are given later.

Without any arguments, ctcl behaves (almost) like tclsh.

If the first argument is a script file, ctcl behaves (almost) like tclsh.

Otherwise, ctcl treats the entire line as a Tcl script. No magic, but very convenient under Windows.

tcl::mathop are autoimported

R:\>ctcl * 2 3
6
R:\>ctcl + {*}[collect [files -pattern *.tcl] eval {file size $_}]
427090

twapi commands are also autoimported.

R:\>ctcl get_process_ids -name notepad.exe
3328 1684

ctcl has its own built-in convenience commands.

R:\>ctcl toclip [read stdin]
This text will go into clipboard
^Z

Useful as a flexible Tcl based filter.

R:\>cat foo.txt | ctcl string toupper [read stdin]

The command line may have compound commands.

R:\>ctcl xargs end_process [get_process_ids -name notepad.exe]

Command may also be continued across multiple lines.

R:\>ctcl foreach pid [get_process_ids -name notepad.exe] {
> puts "Killing PID $pid"
> end_process $pid
> }
Killing PID 2804
Killing PID 2352

Some facilities for pretty printing are included. Dump process information...

R:\>ctcl kl_pp [dict values [get_multiple_process_info -pid -name -virtualbytes]]
   0 System Idle Process                     0
   4 System                            1929216
 272 ati2evxx.exe                     20848640
 400 smss.exe                          3903488
 488 iexplore.exe                    134049792
 640 csrss.exe                        28667904
 664 winlogon.exe                     66490368
 708 services.exe                     22413312
 720 lsass.exe                        42393600
 ...

...or network connections for port 80.

R:\>ctcl kl_pp [get_tcp_connections -matchremoteport 80]
192.168.1.2 3464 209.85.153.100 80 estab     1344 0 firefox.exe C:\Program Files\Mozilla Firefox\firefox.exe
192.168.1.2 3463 209.85.231.100 80 estab     1344 0 firefox.exe C:\Program Files\Mozilla Firefox\firefox.exe
192.168.1.2 3446 209.85.153.132 80 time_wait    0 0
192.168.1.2 3447 209.85.153.132 80 time_wait    0 0