expect hangs at "\# "
- From: cozzmo1@xxxxxxxxxxx
- Date: Fri, 31 Aug 2007 08:50:50 -0700
Hi,
I was hoping someone could help me with a problem.
I'm trying to get the following script to work,
but it always hangs at the "expect -exact "\# ""
Thanks,
Crzzy1
expect -exact "\# "
send -- "\r"
------
the output looks like this.
CES>enable
Password:
CES# term paging off
CES#show run
......lots of output...
CES# (<--hangs here.)
------
#!/usr/local/bin/expect -f
set force_conservative 0 ;# set to 1 to force conservative mode even
if
;# script wasn't run conservatively
originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set hostname [lindex $argv 0]
set timeout -1
set send_human {.1 .3 1 .05 2}
#send -h "I'm hungry. Let's do lunch."
#spawn $env(SHELL)
spawn bash
#spawn /usr/bin/bash
match_max 100000
stty -echo
##telnet to the device
expect -exact "\$ "
send -- "telnet $hostname\r"
##
expect -exact "\:"
send -- "\username"
send -- "\r"
##apply PW
expect -exact "\:"
send "mypassword"
send -- "\r"
expect -exact "\>"
send -- "\enable"
send -- "\r"
expect -exact "\:"
send "mypassword"
send -- "\r"
##apply a command
send -- " term paging off "
send -- "\r"
send "show run"
send -- "\r"
expect -exact "\# "
send -- "\r"
send " show ver"
send -- "\r"
send " term paging on"
send -- "\r"
expect "\# "
send -- " exit\r"
send -- " exit\r"
expect "\$ "
send -- " exit\r"
expect eof
.
- Prev by Date: Re: Restricting execution of the tcl script to a folder or below
- Next by Date: Re: catch replacing useful errorInfo
- Previous by thread: getting user names with twapi
- Index(es):
Relevant Pages
|