telnet session

Discussion in 'Python' started by eight02645999@yahoo.com, Mar 29, 2006.

  1. Guest

    hi
    i am using a telnet session to simulate an authentication mechanism
    USER = "user"
    PASSWORD = "password"
    try:
    telnet = telnetlib.Telnet(HOST)
    telnet.set_debuglevel(5)
    telnet.read_until("login: ")
    telnet.write(USER + "\n")
    telnet.read_until("Password: ")
    telnet.write(PASSWORD + "\n")
    except:
    print "failed to telnet"
    else:
    try:
    telnet.write("ls\n")
    except:
    print "cannot ls"
    else:
    telnet.write("exit\n")
    print telnet.read_all()


    When i purposely input a wrong password, it "hangs" at the login prompt
    waiting for
    login and Password. The host i am telnetting to is a unix server.
    How can i "exit" this login prompt if the user keys in wrong password
    in my script?

    thanks
     
    , Mar 29, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Lambert

    Starting a Telnet Session???

    Mike Lambert, Oct 21, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,385
    Hans Kesting
    Oct 22, 2003
  2. Michael
    Replies:
    1
    Views:
    2,767
    Attila Feher
    Jan 27, 2005
  3. Replies:
    5
    Views:
    20,632
  4. Pekka Niiranen
    Replies:
    4
    Views:
    1,429
    Martin v. =?iso-8859-15?q?L=F6wis?=
    Jun 25, 2003
  5. Christian Wilcox

    displaying extended ASCII from a telnet session

    Christian Wilcox, Jan 9, 2004, in forum: Python
    Replies:
    2
    Views:
    3,703
    Terry Reedy
    Jan 10, 2004
  6. Yannick Turgeon

    Telnet session

    Yannick Turgeon, Aug 3, 2004, in forum: Python
    Replies:
    3
    Views:
    1,087
    Yannick Turgeon
    Aug 6, 2004
  7. Jim Isaacson
    Replies:
    5
    Views:
    827
    Default User
    Nov 5, 2004
  8. Carcarius
    Replies:
    0
    Views:
    475
    Carcarius
    Dec 6, 2007
Loading...