telnet issue



Using following script to telnet to one of FC switch,

proc telnetLogin {user passwd prompt} {
expect {
timeout
{puts "FAIL\nTelnet attempt for $user timed out\n"
return 1
}
eof
{puts "FAIL\nTelnet login prompt for $user never happened\n"
return 1
}
# this is the case where we conenct with the switch
".*login:$"
}
send "$user\r"
expect "Password:"
send "$passwd\r"
expect $prompt
return "0"
}

#
# main
#
.......
.......
set timeout 60

puts "telneting to switch"
spawn telnet $switch
set sw_spid $spawn_id

sleep 5

# exit since it was not possible to connect to the switch
catch {telnetLogin $suser $spasswd $sprompt} code
if {$code != 0} {
puts "unable to access switch"
exit
}

I am getting the following error message,

"Telnet login prompt for xxxxx never happened"

which is the error message from eof in telnetLogin function.

I am thinking "spawn telnet $switch" is not invoking properly.
I would greatly appreciate your feedback.

Thanks.

.



Relevant Pages

  • Re: telnet issue
    ... proc telnetLogin {user passwd prompt} { ... {puts "FAIL\nTelnet login prompt for $user never happened\n" ... puts "telneting to switch" ... spawn telnet $switch ...
    (comp.lang.tcl)
  • Re: telnet issue
    ... {puts "FAIL\nTelnet login prompt for $user never happened\n" ... puts "telneting to switch" ... spawn telnet $switch ...
    (comp.lang.tcl)
  • Re: Linux Expect script - spawn telnet error
    ... expect "Switch Prompt:" ... continue at the next 'spawn telnet 10.10.x.x' section if it fails? ...
    (comp.lang.tcl)
  • Re: Linux Expect script - spawn telnet error
    ... expect "Switch Prompt:" ... continue at the next 'spawn telnet 10.10.x.x' section if it fails? ...
    (comp.lang.tcl)
  • Re: Net::Telnet - Library Application
    ... is my program signing out of the telnet session.. ... sub SetVal ... if (defined $tln) ... TlNet_ClearScreen ('cls', $prompt, 2); ...
    (comp.lang.perl.misc)