Sponsored Content
Top Forums Shell Programming and Scripting Expect/telnet/testing tacacs on a cisco Post 302463916 by popeye on Monday 18th of October 2010 08:15:41 PM
Old 10-18-2010
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"
                                    }
 }

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl telnet to cisco router and compare the ping ms

All Please help, i will telnet to router to obain the ping status and compare, if higher than normal latency, i will have further action.. if i do the telent and in perl script then .... e.g the result i obtain from the router will be =' Success rate is 100 percent (5/5), round-trip... (4 Replies)
Discussion started by: optimus
4 Replies

2. Shell Programming and Scripting

Webpage to Telnet via Perl and Expect: Telnet problem?

Somewhat long story: I have a simple Perl CGI script that uses Expect to Telnet to a device and grab some data, and then spits it back to Perl for display on the Webpage. This works for many devices I've tried, but one device just fails, it keeps rejecting the password on this device, only... (1 Reply)
Discussion started by: jondo
1 Replies

3. Shell Programming and Scripting

Need help with Expect script for Cisco IPS Sensors, Expect sleep and quoting

This Expect script provides expect with a list of IP addresses to Cisco IPS sensors and commands to configure Cisco IPS sensors. The user, password, IP addresses, prompt regex, etc. have been anonymized. In general this script will log into the sensors and send commands successfully but there are... (1 Reply)
Discussion started by: genewolfe
1 Replies

4. Shell Programming and Scripting

perl telnet issue with cisco

Hi Experts, I am using perl to telnet on cisco boxes. We have this stupid cisco node which does not support "terminal Length0" command. Since I am using Net::Telnet and capturing output with @output = $telnet->cmd('cmd'); Say @output = $telnet->cmd('show version'); Now problem... (2 Replies)
Discussion started by: mtomar
2 Replies

5. Shell Programming and Scripting

Perl variables inside Net::Telnet::Cisco Module doesn't work

I am writing perl script to configure Cisco device but Variables inside Net::Telnet::Cisco Module doesn't work and passed to device without resolving. Please advise. here is a sample of script: use Net::Telnet::Cisco; $device = "10.14.199.1"; ($o1, $o2, $o3, $o4) = split(/\./,$device);... (5 Replies)
Discussion started by: ahmed_zaher
5 Replies

6. Shell Programming and Scripting

Bash script failed with expect on cisco routers

Hi all, I use a bash script which use expect to connect throught ssh and run command on a cisco router. The ssh connection with expect work fine, but the first command on the cisco router failed, I try to run the command in error by hand and it work fine... :( the first part of the script... (2 Replies)
Discussion started by: bedomon
2 Replies

7. Shell Programming and Scripting

Perl Telnet cisco routers

Hi all i have little problem finding solution about simple telnet script .... i have 250 routers and on some i have different password and on some they ask just for password no username. So for example 1,2,3 have username and password (user,password) 4, and 5 have different username and password... (0 Replies)
Discussion started by: IvanMP
0 Replies

8. Shell Programming and Scripting

Expect script to show cisco configs

I know there are better ways to do this. I prefer snmp. I do not have the proper perl modules loaded on the platorm. Snmp isnt loaded on the platform. Telnet is not an option. I need to write an expect script to pull cisco equipment configs. The following code is executed once I gain... (0 Replies)
Discussion started by: popeye
0 Replies

9. Shell Programming and Scripting

Cisco, 2 ssh logins for expect /bash

HI all i need to connect to about 900 cisco routers and switch to do some configs changes. the issue i am having is that half the devices have one set of username and password and the other half have another username and password. From expect or bash script i can ssh into a device and make... (0 Replies)
Discussion started by: quintin
0 Replies
RXTELNET(1)						    BSD General Commands Manual 					       RXTELNET(1)

NAME
rxtelnet -- start a telnet and forward X-connections. SYNOPSIS
rxtelnet [-l username] [-k] [-t telnet_args] [-x xterm_args] [-K kx_args] [-w term_emulator] [-b telnet_program] [-n] [-v] host [port] DESCRIPTION
The rxtelnet program starts an xterm window with a telnet to host host. From this window you will also be able to run X clients that will be able to connect securely to your X server. If port is given, that port will be used instead of the default. If setting up the X forwarding failes, rxtelnet will still telnet in to the remote host, but without X forwarding. The supported options are: -l Log in on the remote host as user username. -k Disables keep-alives. -t Send telnet_args as arguments to telnet. -x Send xterm_args as arguments to xterm. -X Send kx_args as arguments to kx. -w Use term_emulator instead of xterm. -b Use telnet_program instead of telnet. -n Do not start any terminal emulator. -v Be verbose. EXAMPLE
To login from host foo (where your display is) to host bar, you might do the following. 1. On foo: rxtelnet bar 2. You will get a new window with a telnet to bar. In this window you will be able to start X clients. SEE ALSO
kx(1), rxterm(1), telnet(1), tenletxr(1), kxd(8) KTH_KRB March 7, 2004 KTH_KRB
All times are GMT -4. The time now is 05:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy