Академический Документы
Профессиональный Документы
Культура Документы
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
What is TCL?
Shell-like syntax
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Control flow
Listing 2: File 1-if
1 #! / u s r / b i n / t c l s h
2
3 set f l a g true
4 if { $flag } {
5
puts True !
6 } else {
7
puts F a l s e !
8 }
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Loops
Listing 3: File 2-loops
1 #! / u s r / b i n / t c l s h
2
3 set input n
4 w h i l e { $ i n p u t != y } {
5
puts Would you l i k e t o q u i t ? <y /n>
6
gets s t d i n i n p u t
7 }
8
9 f o r { s e t i 0} { $ i < 10} { i n c r i } {
10
puts $ i
11 }
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Example
Listing 4: File install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! / u s r / b i n / t c l s h
set
fail
true
w i l l cause spontaneous
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Whitespace
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Whitespace
Listing 6: File 4-iffixed
1
2
3
4
5
6
7
8
9
10
#! / u s r / b i n / t c l s h
set f l a g true
if { $flag } {
puts Yay !
}
if { $flag } \
{
puts Yay !
}
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Whitespace
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Grouping
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Data Structures
Listing 9: File 7-structures
1 #! / u s r / b i n / t c l s h
2
3 s e t m y l i s t { a b c d}
4 puts $ m y l i s t
5 puts [ l i n d e x $ m y l i s t 0 ]
6 puts [ l l e n g t h $ m y l i s t ]
7
8 set myarray ( foo ) bar
9 s e t m y a r r a y ( b a z z ) bu zz
10 p a r r a y m y a r r a y
11 puts $ m y a r r a y ( f o o )
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Procedures
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
What is Expect?
Extension to TCL
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Spawn
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Expect
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Send
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
Autoinstall
#! / u s r / b i n / e x p e c t
spawn . / i n s t a l l
expect I n s t a l l
s e n d y\n
e x p e c t c o m b u s t i o n . C o n t i n u e ? <y /n> {
s e n d n\n
} I n s t a l l w i l l t a k e 10 Gb. C o n t i n u e ? <y /n> {
s e n d y\n
}
expect eof
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
William Tracy
Introduction to TCL
TCL Fundamentals
TCL oddities
More TCL syntax
Introduction to Expect
Expect fundamentals
Expect examples
The end
The book
William Tracy