Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expect - Interact hangs when executing command with large output

Status
Not open for further replies.

nathanhilderman

Programmer
Aug 27, 2008
1
CA
Hello,
I have a simple expect script I use to ssh to a workstation. I then pass control over to the user with interact.
This script works fine when executed on my HP and Mac, but on my Linux Desktop, I get a problem where the terminal hangs ( or actually loops through the output indefinitely) when ever I execute a command in the interact session that requires a fairly large output to be dumped.

For example, if I run "ls" on a directory with a lot of files, it seems like the output just loops indefinitely (I see the files in the directory repeatedly) and I don't get control back. I can't even stop it with ctrl-c , I need to kill the process.

I tried setting option: interact -nobuffer with no success. I have also tried xterm and gnome terminal, but no success. I have a feeling it has to do with the speed of the output, or the buffer size of expect or interact. I have also seen this on other scripts using expect without interact. Any suggestions?

Below is my expect script:

#!/usr/bin/expect

if {[llength $argv] < 1 } {

puts "Incorrect arguments. Enter following syntax:\n"
puts " tn <node to telnet to> \n\r"
puts "Example: \n"
puts " tn ottud023 \n\r\n\r"
exit 1

}

set wsname [lindex $argv 0]
set displayno 0
set timeout 15

exec xhost +

spawn ssh $wsname -l $UserID
set spwnid1 $spawn_id

expect {
-i $spwnid1
"login" {
send "$UserID\n"
}
"Password" {
send "$Passwd\n"
}
"password" {
send "$Passwd\n"
}
timeout {
send_user "TIMEOUT\n"
}
}

# clear out buffer
expect -re {.*} {}

interact -nobuffer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top