07-13-2020, 14:10 +0200
AuthorPost
sumguy  05-17-2013, 16:51   | Expect not completing a loop.
Member since 05/2013
3 Posts
I have another problem I cant figure out. When I initially wrote this it was working fine.

Today, it looks like the script is moving on to the next iteration without finishing the first.


                                                                                                                              
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
set iseed [open "seed" r]
set timeout 20
set taclnam "username"
set tacpswd "password"
while { [gets $iseed ip] >=0 } {
    spawn ssh -l $taclnam $ip
    #
    expect {
        "yes/no"        {
            send  "yes\n"
            expect -re "assword"
            send  "$tacpswd\r"
        }
        "sername"       {
            send  "$taclnam\r"
            expect -re "assword"
            send  "$tacpswd\r"
        }
        "assword"       {
            send  "$tacpswd\r"
            expect ">"
            send "enable\n"
            wait 2
            expect  "assword:"
            send "$tacpswd\n"
        }
        timeout         { puts "\nConnection timed out. Incorrect password.\n"}
        default         {
            puts "Login FAILED\N"
            continue
            #exit
        }
    }

    #

}
#close connectivty while
close $iseed




The output

spawn ssh -l username 10.22.19.24
Username@10.22.19.24's password:
Router1>enable
Password: spawn ssh -l username 10.23.76.35
C

+-------------------------------------------------------------------------------+
|                                                                       |
|       router banner                   
+-------------------------------------------------------------------------------+
Password:
Password:
Password:
Advanced options for this topic:

Ignore this topic (Do not list this topic in the "unread topics" search. You are currently not ignoring this topic.)
Hide this topic (Hidden topics are not displayed in the topics list. This topic is currently not hidden.)
Go to forum

Unclassified NewsBoard 1.5.3-d | © 2003-4 by Yves Goergen | Time: 182.6 msec, CPU time: 90.8 msec, 30 Database queries in 127.7 msec | 3.3 kB (14.2 kB) | Timezone: +0200