cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1440
Views
0
Helpful
1
Replies

Using plink to connect to pix works (ssh), to switch doesn't work (telnet)

murray-davis
Level 1
Level 1

I want to automate a few things using plink. I can connect interactively to a cisco pix using the following command:

plink -ssh -l username -pw password -m testconpix.txt 10.1.1.2

The contents of testconpix is:

en

enablepassword

sh arp

This works fine. I am authenticated and the output of the arp table is displayed.

Now, I would like to do the same to connect to a cisco switch using the following command:

plink -telnet -m testconsw.txt 10.1.1.10

The contents of testconsw.txt are;

telnetpw

en

enablepw

sh ip arp

However, I am prompted for the telnet password at the command line. It appears that the plink command is unable to read the file. What do I have to do to get plink to read the file interactively to logon and issue the commands?

1 Reply 1

murray-davis
Level 1
Level 1

Well, I figured it out. Apparently, telnet can only read from the command line, not from a text file. So, I switched to the python programming language because it has a telnetlibrary and used the following script: telnet.py. I ran this script from a command line. The script logs on interactively and then prints out the arp table of the switch.

import telnetlib

HOST = "10.1.1.10"

tn = telnetlib.Telnet(HOST)

tn.read_until("Password: ")

tn.write("telnetpassword\n")

tn.write("en\n")

tn.read_until("Password: ")

tn.write("enablepassword\n")

tn.write("sh arp\n")

tn.write("exit\n")

print tn.read_all()

Review Cisco Networking products for a $25 gift card