Expect - Interact output hangs when large output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect - Interact output hangs when large output
# 1  
Old 08-27-2008
Expect - Interact output hangs when large output

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 on my HP and Mac, but on my Linux Desktop, I get a problem where the terminal hangs 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 a feeling it has to do with the speed of the output, or the buffer size of 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


Last edited by natedog; 08-27-2008 at 03:50 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture output from expect script

Hi I am new to Expect scripting. I have to connect to a remote server and capture the output. Here I need output of " send "list registered\r"" to be stored in a file. but after execution, /tmp/capture.txt is of 0 byte #!/usr/bin/expect spawn ssh abc@10.10.10.10 -p 5022 expect... (2 Replies)
Discussion started by: bns928
2 Replies

2. UNIX for Advanced & Expert Users

Expect and interact

I am trying to log on to server as a normal user and then sudo to root. I am using below expect script. $ cat SC.orig expect <<EOF # | tee -a $LOGFILE spawn sshpass -p "mypassword" ssh -l myid nim expect "$" send "sudo su - root\n" expect "Password:" send "mypassword\n"; sleep 4... (3 Replies)
Discussion started by: sri243
3 Replies

3. Shell Programming and Scripting

How do I use grep output in an expect script?

Hi, I am using expect to ssh to a remote host and run a program on the remote machine which has a variable runtime. I need to wait until it finishes so I can grab the output file of this program. I am trying to use the output of grep to know when the process finishes. I am trying to capture... (0 Replies)
Discussion started by: vagabond1964
0 Replies

4. Shell Programming and Scripting

Expect script - Interact help

Hi Guys, Further to my post yesterday I have got round the issue of not being able to use expect by using one of our unix machines to have the script running instead of the jumpbox itself. However my issue is I now have an extra bit it the script which is shh to the jumpbox which requires a ras... (1 Reply)
Discussion started by: mutley2202
1 Replies

5. Shell Programming and Scripting

Piped output from SSH tunnel hangs?

Hi All, When starting an SSH tunnel, piped output 'hangs' (on AIX) : ssh -Nf -Llocalhost:22000:server:22 proxy | cat -vet - ... hangs ... Does anybody know how to prevent this? Of course, in my script I don't use the tunnel as I do in the example above. In my script the call to ssh is... (7 Replies)
Discussion started by: whbos
7 Replies

6. Shell Programming and Scripting

Expect debug output

Hi! I want to start OO in headless mode via expect - the oo command would be su - root -c "/usr/lib/openoffice/program/soffice -headless -nofirststartwizard -norestore -nolockcheck -nocrashreport -nodefault -accept='socket,host=0.0.0.0,port=8100;urp;StarOffice.Service'" and the expect... (2 Replies)
Discussion started by: senior.weber
2 Replies

7. Shell Programming and Scripting

Expect script exiting too fast if used without interact.

Hi I'm working on an Expect script that is supposed to log-into a remote server and run some steps and exit. In the script I first spawn a 'ssh' session to the server and then after logging in I 'send' all the necessary steps ( with a '\r' at the end, so that they get automatically executed the... (3 Replies)
Discussion started by: clakkad
3 Replies

8. Shell Programming and Scripting

How can I scroll the terminal output with Expect

Hi, I'm trying to come up with a simple expect script that allows me to login to a system and run a single command ... something like this: #!/usr/bin/expect -f # let's set some variables #set password set ipaddr set ponumber set hostname set timeout -1 # let's now connect to the... (0 Replies)
Discussion started by: danielsf
0 Replies

9. Shell Programming and Scripting

want to use output of c programme in expect

hi i am having a c code which gives the output of my password in text format i.e when i run my c code which which gives the password asfollows====>>>>>> $./passwdprogram ======>>>>>>abc@123(this is the output) now i have an expect script to remotely ssh which uses the password set in ... (0 Replies)
Discussion started by: xander
0 Replies

10. Shell Programming and Scripting

Get the output from EXPECT ?

I'm using expect script, but don't know how to assign an output to a string variable. Any help ? Thank you for reading! PS: In fact i want to get the out put of expect when run grub-md5-crypt to generate MD5 password for GRUB boot loader. My code:#!/bin/sh #\ exec expect -f "$0" ${1+"$@"}... (4 Replies)
Discussion started by: fongthai
4 Replies
Login or Register to Ask a Question