I use tcl to connect a legacy remote telephone switch, and it fails.Normally a telnet session is working but script.
The script is as folows;
!/nortel/netWORKS2/bin/tclmodel
set ip [lindex $argv 0]
set port [lindex $argv 1]
exp_internal -f "/tmp/dms_tst.out" 1
set timeout 40
spawn telnet $ip $port
expect -re "Escape" {send "^]\r"}
sleep 6
expect telnet> {send "send brk\r"}
sleep 6
expect "*\?*" {send "login\r"}
sleep 9
expect "*\>*" {send "NMSCONTROL\r"}
expect Enter {send "CONCON\r"}
expect > {send "listsf all\r"}
sleep 5
. . .
. .
.
I picked up logs inside the script via exp_internal command:
spawn telnet ta10 2300
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {18040}
expect: does "" (spawn_id 9) match regular expression "Escape"? no
Trying...
Connected to ta10.
Escape character is '^]'.
expect: does "Trying...\r\nConnected to ta10.\r\nEscape character is '^]'.\r\n"
(spawn_id 9) match regular expression "Escape"? yes
expect: set expect_out(0,string) "Escape"
expect: set expect_out(spawn_id) "9"
expect: set expect_out(buffer) "Trying...\r\nConnected to ta10.\r\nEscape"
send: sending "\x1d\r" to { 9 }
expect: does " character is '^]'.\r\n" (spawn_id 9) match glob pattern "telnet>"
? no
^]
expect: does " character is '^]'.\r\n\x1d\r\n" (spawn_id 9) match glob pattern "
telnet>"? no
telnet>
expect: does " character is '^]'.\r\n\x1d\r\n\r\ntelnet> " (spawn_id 9) match gl
ob pattern "telnet>"? yes
expect: does " character is '^]'.\r\n\x1d\r\n" (spawn_id 9) match glob pattern "
telnet>"? no
telnet>
expect: does " character is '^]'.\r\n\x1d\r\n\r\ntelnet> " (spawn_id 9) match gl
ob pattern "telnet>"? yes
expect: set expect_out(0,string) "telnet>"
expect: set expect_out(spawn_id) "9"
expect: set expect_out(buffer) " character is '^]'.\r\n\x1d\r\n\r\ntelnet>"
send: sending "send brk\r" to { 9 }
expect: does " " (spawn_id 9) match glob pattern "*?*"? yes
expect: set expect_out(0,string) " "
expect: set expect_out(spawn_id) "9"
expect: set expect_out(buffer) " "
send: sending "login\r" to { 9 }
expect: does "" (spawn_id 9) match glob pattern "*>*"? no
send brk
login
expect: does "send brk\r\nlogin\r\n" (spawn_id 9) match glob pattern "*>*"? no
expect: timed out
expect: does "send brk\r\nlogin\r\n" (spawn_id 9) match glob pattern "Enter"? no
Can anyone advise me what can I do to correct logon script ??
The script is as folows;
!/nortel/netWORKS2/bin/tclmodel
set ip [lindex $argv 0]
set port [lindex $argv 1]
exp_internal -f "/tmp/dms_tst.out" 1
set timeout 40
spawn telnet $ip $port
expect -re "Escape" {send "^]\r"}
sleep 6
expect telnet> {send "send brk\r"}
sleep 6
expect "*\?*" {send "login\r"}
sleep 9
expect "*\>*" {send "NMSCONTROL\r"}
expect Enter {send "CONCON\r"}
expect > {send "listsf all\r"}
sleep 5
. . .
. .
.
I picked up logs inside the script via exp_internal command:
spawn telnet ta10 2300
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {18040}
expect: does "" (spawn_id 9) match regular expression "Escape"? no
Trying...
Connected to ta10.
Escape character is '^]'.
expect: does "Trying...\r\nConnected to ta10.\r\nEscape character is '^]'.\r\n"
(spawn_id 9) match regular expression "Escape"? yes
expect: set expect_out(0,string) "Escape"
expect: set expect_out(spawn_id) "9"
expect: set expect_out(buffer) "Trying...\r\nConnected to ta10.\r\nEscape"
send: sending "\x1d\r" to { 9 }
expect: does " character is '^]'.\r\n" (spawn_id 9) match glob pattern "telnet>"
? no
^]
expect: does " character is '^]'.\r\n\x1d\r\n" (spawn_id 9) match glob pattern "
telnet>"? no
telnet>
expect: does " character is '^]'.\r\n\x1d\r\n\r\ntelnet> " (spawn_id 9) match gl
ob pattern "telnet>"? yes
expect: does " character is '^]'.\r\n\x1d\r\n" (spawn_id 9) match glob pattern "
telnet>"? no
telnet>
expect: does " character is '^]'.\r\n\x1d\r\n\r\ntelnet> " (spawn_id 9) match gl
ob pattern "telnet>"? yes
expect: set expect_out(0,string) "telnet>"
expect: set expect_out(spawn_id) "9"
expect: set expect_out(buffer) " character is '^]'.\r\n\x1d\r\n\r\ntelnet>"
send: sending "send brk\r" to { 9 }
expect: does " " (spawn_id 9) match glob pattern "*?*"? yes
expect: set expect_out(0,string) " "
expect: set expect_out(spawn_id) "9"
expect: set expect_out(buffer) " "
send: sending "login\r" to { 9 }
expect: does "" (spawn_id 9) match glob pattern "*>*"? no
send brk
login
expect: does "send brk\r\nlogin\r\n" (spawn_id 9) match glob pattern "*>*"? no
expect: timed out
expect: does "send brk\r\nlogin\r\n" (spawn_id 9) match glob pattern "Enter"? no
Can anyone advise me what can I do to correct logon script ??