Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

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

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
New Member

Re: Using plink to connect to pix works (ssh), to switch doesn't

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()

1077
Views
0
Helpful
1
Replies
CreatePlease to create content