#!/usr/bin/expect -f # set myarg [lindex $argv 0] set myexp "\\\[" set filename "input.txt" set input [open $filename "r"] gets $input line puts "from file: = $line" close $input proc do_it { exp } { global logfile puts "do_it: expecting $exp" send -- "ls\r" expect { timeout { puts "timed out!!" } $exp } } puts "myexp:$myexp and argument:$myarg" set timeout 5 spawn $env(SHELL) match_max 100000 do_it $line