expect hangs at "\# "



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

.



Relevant Pages

  • Re: autoconnect to telnet server.
    ... you can use an expect script to accomplish this... ... I would like to use the telnet client via with cron & script to ... dont speak here about security). ...
    (Fedora)
  • Need some help on this script
    ... I am relatively new to expect and I am trying to create a script to ... add user accounts to some dis. ... I am utilizing sudo to invoke useradd ... set force_conservative 0;# set to 1 to force conservative mode even ...
    (comp.lang.tcl)