Expect-5.32.1 and Hangups when Spawning a Shell

Martin McCormick martin at dc.cis.okstate.edu
Wed Dec 14 07:17:57 PST 2005


	Has anyone seen a condition in FreeBSD4.7 in which
expect-5.32.1 randomly hangs when spawning a shell?

	I got this idea from running autoexpect:

spawn $env(SHELL)

	Then, I would look for the prompt and begin executing
commands.

	About every 20 or 30 times, no shell spawns and the script
just hangs there with 1 virtual terminal seized until someone kills
the process.  Since the particular expect script is run automaticly,
one can run out of tty's in a few weeks if this happens often enough
or one doesn't clean house regularly.

	What I recently tried is to set conservative mode to 1 so it
will output data more slowly although I can't imagine how this really
helps.

	Strangely enough, it has been several days since I made the
change and I haven't had to zap one single expect script.

	Is that just coincidence or could the timing of the spawn
command actually matter?  Remember, this is before the shell ever
starts.

	Here is what the beginning of the script now looks like:

#!/usr/local/bin/expect -f

if {$force_conservative} {
	set send_slow {1 .1}
	proc send {ignore arg} {
		sleep .1
		exp_send -s -- $arg
	}
}

spawn $env(SHELL)
match_max 100000
expect -exact "bash-2.05b# "

	When it fails, the prompt never appears.

	Any ideas as to why this occasionally happens or whether my
slow-down of the "typed" output should help is much appreciated.

Martin McCormick WB5AGZ  Stillwater, OK 
OSU Information Technology Department Network Operations Group
.-- -... ..... .- --. --..


More information about the freebsd-questions mailing list