TCL Basics
TCL Basics
Intel Confidential
1 Intel Confidential Intel Labs (STPL/BDL)
Agenda
• Introduction
• TCL Script
• TCL Basics
• TCL Control Flow
• TCL String
• TCL List
• TCL Array
• File I/O and Program Access
• Regular Expression
• Advanced TCL scripting
[unix]$ tclsh
% puts “Hello World!”
Hello World!
% source hello_world.tcl
Hello World!
% exit
[unix]$
[unix]$ tclsh
[unix]$ tclsh % array get a_array
% array get a_array x xyz m mno a abc
x xyz m mno a abc % set a [ array get a_array ]
% array exist a_array x xyz m mno a abc
1 % lindex $a 2
% array size a_array m
3 % array set b_array $a
% array names a_array % array get b_array
x m a x xyz a abc m mno
[unix]$ tclsh
% file rename abc.txt hello.txt
[unix]$ tclsh % proc b { fid } {
% file dirname /nfs/iind/home/kpsahu5/run_apr.csh while { ![eof $fid ] } {
/nfs/iind/home/kpsahu5 gets $fid line; puts $line;
% file tail /nfs/iind/home/kpsahu5/run_apr.csh } }
run_apr.csh % set fid [ open "hello.txt" r ]
% file exists /nfs/iind/home/kpsahu5/run_apr.csh file6
1 % b $fid
% exit hello
world!!!
calc.tk