HELP_REQ: (Expect)Process hangs after rlogin
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

HELP_REQ: (Expect)Process hangs after rlogin

From: Robert Langdon <anti@material.ch>
Date: Fri Jul 29 2005 - 22:49:00 CEST

Hello Everybody,

The purpose of the following script is to use one standard login
procedure for many different actions (cases). It is to
avoid repeated "login procedures" in each particular action. Though it
logs in properly, it hangs afterwards. It stucks at the router prompt
without issuing the next command, in the example below "sh hosts".

Any ideas?

Cheers,

R.

########### Begin script ###################################

#!/usr/bin/expect --
#log_file -noappend /tmp/cisco.log

set vtypasswd bobsname
set enablepasswd bobspasswd

set router [lindex $argv 0]

array set RouterIP {
        i 172.18.36.2
        p 192.168.0.1
        }

array set RouterName {
        i ISDNGW
        p X25GW
        }

proc rtr_telnet { rtr_ip vtypasswd rtr_name en_pass } {
     spawn telnet -K $rtr_ip
      expect {
                 -nocase -re "Password: " {
       exp_send "$vtypasswd\r"
       expect -nocase -re "$rtr_name>"
       exp_send "en\r"
       expect -nocase -re "password: *$"
       exp_send "$en_pass\r"
       expect -nocase -re "$rtr_name#"
# interact
       exp_continue
            }
   }
}

#exp_internal 1
rtr_telnet $RouterIP($router) $vtypasswd $RouterName($router)
$enablepasswd
expect {
   -nocase -re "$RouterName($router)" {exp_send "sh hosts\r"}
   }
exit
interact
Received on Thu Sep 29 14:28:00 2005