|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Expect/telnet/testing tacacs on a cisco
At times I find the need to test that the tacacs port 49 is open. The code below works but is painfully slow because I have to wait on the timeouts. Examples of possible responds router1#telnet 10.11.20.14 49 Trying 206.112.204.140, 49 ... Open [Connection to 206.112.204.140 closed by foreign host] route1#telnet 10.11.19.14 49 Trying 206.112.196.84, 49 ... % Connection timed out; remote host not responding End Examples I would like to capture and act on the "Trying" lines ... Open = tacacs port good ... = tacacs port bad end remote telent end local telnet But I dont know how to tell expect how to grab those responses from the router. Help would be much appreciated. The entire code is given below. Code:
while { [gets $ifil host] >=0 } {
#
set timeout 600
spawn telnet $host
expect ":"
send "myusername\n"
expect ":"
send "mypassword\n"
expect ">"
send "en\n"
expect ":"
send "mypassword2\n"
expect "#"
sleep 3
send "telnet 10.11.19.14 49\n"
expect {
{Connection to} {
puts "$host tacacs ok"
}
{Connection timed out} {
puts "$host tacacs nok"
}
} |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
do you have to use expect/telnet? develop a simple socket program in Perl, Python or whatever langauge. nc is also a great utility to test something like this.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help with Expect script for Cisco IPS Sensors, Expect sleep and quoting | genewolfe | Shell Programming and Scripting | 1 | 10-01-2009 11:12 AM |
| Webpage to Telnet via Perl and Expect: Telnet problem? | jondo | Shell Programming and Scripting | 1 | 07-22-2008 12:35 AM |
| Perl telnet to cisco router and compare the ping ms | optimus | Shell Programming and Scripting | 4 | 08-27-2007 02:28 AM |
| Testing telnet connections in a script | dikiee | Shell Programming and Scripting | 0 | 01-12-2007 08:40 AM |
|
|