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

Unanswered Question
May 14th, 2008
User Badges:

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
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
Loading.
murray-davis Wed, 05/14/2008 - 13:15
User Badges:

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


Actions

This Discussion