verWire3619 |
09-02-2011 12:48 PM |
Another one . . . . telnet: connect to address 127.0.0.1: Connection refused
CentOS release 5.5 (Final)
I'm not new to linux, but very new to networking. I apologize. I'm sure there's prob an answer, but I'm not sure what I'm looking at.
I have this expect script:
Code:
#!/usr/bin/expect -f
exp_internal 1
set stp [lindex $argv 0]
set logfile [lindex $argv 1]
set timeout 1800
spawn /usr/local/bin/$stp
match_max 100000
expect -exact "Trying"
expect -exact "Connected to"
expect -exact "Escape character is '^\]'.\r\r
"
expect -exact "Select a terminal from the list below:"
sleep 2
send -- "23\r"
expect -exact "Connection established as terminal"
sleep 2
send -- "login:uid=userid\r"
expect -exact "Enter Password :"
send -- "passwd\r"
expect -exact "User logged in on terminal"
expect -exact ";\r"
sleep 2
log_file -noappend $logfile
send -- "rtrv-slk\r"
expect -exact "Command Accepted"
expect -exact "SLK table is"
expect -exact ";\r"
log_file
sleep 2
send -- "logout\r"
expect -exact "Command Completed."
send -- ""
expect -exact "\r
telnet> "
send -- "close\r"
expect eof
/usr/local/bin/$stp looks like this
Code:
#!/bin/bash
FLOOR=1024
lport=0 #initialize
while [ "$lport" -le $FLOOR ]
do
lport=$RANDOM
done
echo "Generating random local port --- $lport"
echo "IMPORTANT: Use Ctrl-] , close to exit"
echo
/usr/bin/ssh -f -N -L $lport:127.0.0.1:23 ncstp
sleep 1
/usr/bin/telnet localhost $lport
I turned diagnostic tracking on in the expect script and got:
Quote:
spawn /usr/local/bin/gotostpnc
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {13443}
expect: does "" (spawn_id exp6) match exact string "Trying"? no
Generating random local port --- 28154
expect: does "Generating random local port --- 28154\r\n" (spawn_id exp6) match exact string "Trying"? no
IMPORTANT: Use Ctrl-] , close to exit
expect: does "Generating random local port --- 28154\r\nIMPORTANT: Use Ctrl-] , close to exit\r\n\r\n" (spawn_id exp6) match exact string "Trying"? no
ssh_exchange_identification: Connection closed by remote host
expect: does "Generating random local port --- 28154\r\nIMPORTANT: Use Ctrl-] , close to exit\r\n\r\nssh_exchange_identification: Connection closed by remote host\r\r\n" (spawn_id exp6) match exact string "Trying"? no
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
expect: does "Generating random local port --- 28154\r\nIMPORTANT: Use Ctrl-] , close to exit\r\n\r\nssh_exchange_identification: Connection closed by remote host\r\r\nTrying 127.0.0.1...\r\r\ntelnet: connect to address 127.0.0.1: Connection refused\r\n" (spawn_id exp6) match exact string "Trying"? yes
expect: set expect_out(0,string) "Trying"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "Generating random local port --- 28154\r\nIMPORTANT: Use Ctrl-] , close to exit\r\n\r\nssh_exchange_identification: Connection closed by remote host\r\r\nTrying"
expect: does " 127.0.0.1...\r\r\ntelnet: connect to address 127.0.0.1: Connection refused\r\n" (spawn_id exp6) match exact string "Connected to"? no
expect: read eof
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) " 127.0.0.1...\r\r\ntelnet: connect to address 127.0.0.1: Connection refused\r\n"
expect: spawn id exp6 not open
while executing
"expect -exact "Escape character is '^\]'.\r\r
""
(file "/home/ss7/bin/links.exp" line 13)
|
This expect script is in a loop in a perl script for 4 network elements. I'm able to make connection to 2 of the 4 elements. This was working at one time.
I do not know what changed.
I'm not sure where to begin to troubleshoot.
Any guidance is much appreciated.
Thanks!
|