#!/usr/bin/expectk log_user 0 eval spawn -noecho "/usr/local/icp/bin/icp" set icpid $spawn_id text .icp text .out entry .input -relief sunken -bd 1 button .howlongbut -text "Howlong i1-6" -command {exp_send -i $icpid "howlong i1-6\r"} pack .icp -fill x -anchor nw -expand true pack .input -fill x pack .howlongbut pack .out -fill x -anchor nw -expand true expect_background { -i $icpid -re "( I \[^\r]+)\r\n" { #regexp {.+\:.+([0-9].+) Mins.+\=.+([0-9].+\.[0-9].+) Hrs.*} $expect_out(1,string) ignore indiv total regexp ".+(\[0-9]+).+(\[0-9]+).+Mins.+(\[0-9]+\.\[0-9]+).+Hrs.*" $expect_out(1,string) ignore ibuf indiv total .out insert end "Howlong = $indiv / $total \n" .icp insert end $expect_out(1,string) .icp insert end "\n" } -i $icpid -re "\[^\x0d]+" { .icp insert end $expect_out(0,string) } -i $any_spawn_id "\x0d" { } -i $any_spawn_id "exit" { exit 0 } } foreach event { <>} {bind .icp $event break; bind .out $event break} bind .input {focus %W} bind .input {exp_send -i $icpid [ .input get]; exp_send -i $icpid "\r"; .input delete 0 end }