Posted to tcl by kbk at Wed Mar 21 19:41:32 GMT 2018view raw
- #!/no_backup/ActiveTcl-8.6/bin/tclsh
- package require Expect
- # exp_internal 1
- spawn /bin/sh
- expect {$ }
- send "ls -1\n"
- expect \r\n
- expect {
- -re {^([^\r\n]*\.tcl)\r} {
- set fname $expect_out(1,string)
- puts "Tcl file: $fname"
- exp_continue
- }
- -re {^([^\r\n]*)\r} {
- set fname $expect_out(1,string)
- puts "Non-Tcl file: $fname"
- exp_continue
- }
- -re {^[^\r\n]*\$ $} {
- puts "Got shell prompt again."
- }
- -re {[^\n]*\n} {
- exp_continue
- }
- timeout {
- puts "Timeout before all patterns matched."
- }
- }
- send exit\r\n
- expect eof