Strange expect problem


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Strange expect problem
# 1  
Old 11-06-2007
Strange expect problem

Hi

I'm writing a script which calls an expect script to retrieve configuration files for network devices. I want to avoid using TFTP to transfer the configs if possible and so I'm redirecting the screen output to a text file.

This is the expect script:

#!/usr/local/bin/expect

set HOSTNAME [lindex $argv 0]
set USERNAME [lindex $argv 1]
set PASSWORD [lindex $argv 2]

set timeout 10

spawn /usr/local/bin/ssh -1 $USERNAME@$HOSTNAME
expect "word:"
send "$PASSWORD\r"
expect "#"
send "terminal length 0\r"
expect "#"
sleep 1
log_file /{$LOGFILEPATH}/$HOSTNAME-running.txt
send "show running-config\r"
expect "#"
sleep 1
log_file
send "logout\r"

exit 0


It works really well for most devices, so I'm not too hung up on the exact syntax of the script, but I'm having real problems with a couple of devices. The only thing that these problem devices seem to have in common is that the configs are bigger than usual. What happens is that around 85% of the config gets output and then the script just halts and won't go any further.

I've played around with the timeouts and the sleep commands and it seems to make no difference at all.

I've run it in debug mode and can't see any problems other than the fact that it just stops 85% the way through the config output. There are no # characters or anything else in the configs that could trigger a premature send either.

I thought maybe the expect buffer wasn't big enough but all I've read on the internet suggests that the buffer shouldn't be a problem. I'm pretty stumped as to why it just halts. As I said it works fine on most other devices.

Any ideas anyone?

Thanks.
# 2  
Old 11-09-2007
OK. Nobody seems to know the answer to this one Smilie

Anybody know any other method of doing it with an expect script apart from TFTP?
# 3  
Old 02-12-2009
expect script sun problem

Hi there,

I have downloaded expect on my AIX 5.3
uncompress expect.tar.Z
tar -xvf expect.tar

Now I have the directory /usr/local/expect-5.43

I try to run the

autoexpect telnet 10.0.10.17

from the /usr/local/expect-5.43/example/ directory and it says

and it says ksh: autoexpect: not found.

Any Ideas?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

strange problem

hello all, i am having problem in accessing a directory.I dont think its a permission issue.can anyone help me out. I am using korn sell code: $ ls -ltr sc* lrwxrwxrwx 1 essbase essbase 21 Oct 8 2010 sc_ssp -> /work/nfs/nas2/sc_ssp $ cd sc_ssp ksh: sc_ssp: not found $ (6 Replies)
Discussion started by: manid
6 Replies

2. Shell Programming and Scripting

Strange Problem

Hi All, I am encountering an unexpected problem while running my process, using daemon placed in /etc/init.d/. I have a process that is opening shared library using dlopen. When I run my process on the command line, it is able to open the library. But when I used daemon to run my process, I... (0 Replies)
Discussion started by: qwerty-1
0 Replies

3. Shell Programming and Scripting

Expect script strange behaviour

Hi people, I'm having some strange behaviour with an 'expect' script. spawn csession blah expect "Username: " send "userblah\r" expect "Password: " send "passwordblah\r" interact When I execute the script as root it runs perfectly. However, when executed as any other... (0 Replies)
Discussion started by: GarciasMuffin
0 Replies

4. Shell Programming and Scripting

strange expect script behavior, or am i misunderstanding expect scripting?

Hello to all...this is my first post (so please go easy). :) I feel pretty solid at expect scripting, but I'm running into an issue that I'm not able to wrap my head around. I wrote a script that is a little advanced for logging into a remote Linux machine and changing text in a file using sed.... (2 Replies)
Discussion started by: v1k0d3n
2 Replies

5. Shell Programming and Scripting

Strange problem.

Well, my script started off to do what i wanted. Now, i think its not recognizing the pattern so its not moving anything. What i have to do is execute my script command for the move to take effect. So i did that and yayy it worked. Strange thing is that my DESTDIR was empty to begin with.... (2 Replies)
Discussion started by: oxoxo
2 Replies

6. Shell Programming and Scripting

Strange problem

I am using SunOS 5.9 and I don't know why all my commands are getting executed as if an extra 'enter' has been pressed. What could be the reason and how to correct it? Please help. Asty (2 Replies)
Discussion started by: Asty
2 Replies

7. Linux

very strange problem

I have installed Fedora Core on a Toshiba Satellite Pro4600 laptop recently I have experienced a rather mysterious problem if I touch anything specially the keyboard or mouse I see this stuff “67yujhnmyyy” straight away some time it won't stop for while like this... (5 Replies)
Discussion started by: kemobyte
5 Replies

8. UNIX for Dummies Questions & Answers

strange...problem

Hi.. Some of my application were not running properly due to lack of virtual memory.....so wht i did add one free harddisk as swap file system...and increased the swap memory.. But since than my root file system is showing 100% full thr is no space left...is thr any link between these two..... (1 Reply)
Discussion started by: Prafulla
1 Replies

9. UNIX for Dummies Questions & Answers

Strange Problem

I did an installation of Redhat 7.1 and it seem to install smoothly. I go and reboot and I get the following message: "INIT: Id "x" respawing too fast: disabled for 5 minutes" The screen flashes 4 times every 10 seconds or so. I can't seem to figure why this does this. It might be a simple... (2 Replies)
Discussion started by: forjohnny
2 Replies

10. UNIX for Dummies Questions & Answers

Strange problem.Please Help !

I¡¯m a network operator, mine is an IBM PC server 320, operating system SCO unix 3.2v4.2, triton 3.1 of Baan. Recently, my server went dead every a few hours, no sign & signal shows malfunction suddenly. It looks like a sudden power failure, but the indicator of main power supply is on. Normal... (1 Reply)
Discussion started by: lyhsm
1 Replies
Login or Register to Ask a Question