Posted to tcl by rical at Tue Jan 17 14:25:14 GMT 2012view raw
- #!/usr/bin/tclsh
- package require Expect
- log_user 0
-
- spawn "/bin/bash"
- set timeout 1
-
- # #
- # Controll
- puts "Controll"
- send "cat ex.list\n"
- expect {
- -re {match 2: ([[:alpha:]]+)} {puts "2 = $expect_out(1,string)."}
- default {puts "failed"}
- }
- expect *
-
- # #
- # Dynamic
- set two 2
- lappend body "-regexp"
- lappend body "match $two: (\[\[:alpha:]]+)"
- lappend body "puts {$two = \$expect_out(1,string).}"
- lappend body default {puts "failed"}
-
- puts "body: $body"
-
- puts "Dynamic2"
- send "cat ex.list\n"
- expect $body
-