Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6032223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:18:08+00:00 2026-05-23T05:18:08+00:00

I am trying to telnet into a Cisco Switch and run a couple of

  • 0

I am trying to telnet into a Cisco Switch and run a couple of commands on it. I am able to check if the host doesn’t exist, not sure how to check if the username or password is correct. This is what I got so far(This is part of my class)

def login(self):
    if self.user_name and self.password: 
        try:
            self.connection=telnetlib.Telnet(self.telnet_host)
            try:
                self.connection.read_until('sername:',1)
                self.connection.write(self.user_name+'\r\n')
                self.connection.read_until('assword:',1)
                self.connection.write(self.password+'\r\n')
                self.connection.read_until(self.prompt,1)
                print "Connected"
                self.loggedON=True
            except EOFError:
                print "Authentication to "+ self.telnet_host+" failed.\n"
                return
        except: 
            print "Can't connect to "+self.telnet_host+"\n"
            return
    else:
        if not self.user_name:
            self.user_name=raw_input("Username: ")
            self.login()
        else:
            self.password=raw_input("Password: ")
            self.login()

It will still say it is connected even if the wrong password or username.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:18:09+00:00Added an answer on May 23, 2026 at 5:18 am

    You could also try Exscript:

    from Exscript.util.start import quickstart
    
    def do_something(conn):
        conn.autoinit()
        conn.execute('show version')
    
    quickstart('telnet://localhost', do_something)
    

    The quickstart() function asks the user for username and password (use start() if that is not what you want). Login failure (and other errors) are handeled automatically. You may also want to look at Exscript.util.start.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Linux box and I want to be able to telnet into
I can telnet to a certain host and port no problem and issue commands.
I'm trying to check if a file exists or not in Tcl, but I
How can I run telnet inside a shell script and execute commands on the
I am trying to establish a local telnet session in C++ and send commands/receive
Trying to build out an exception if move.UserId does not equal currentUserId then Redirect
Trying to copy the msdn refernce here doesn't work and gives an error I
trying to understand http and headers i was playing around with telnet to send
I am trying to run an app which is using a kernel mode driver.
I'm trying to send commands to the Tor control port programmatically to make it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.