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. Advertising

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,243
    Hans Kesting
    Oct 22, 2003
  2. Michael
    Replies:
    1
    Views:
    2,667
    Attila Feher
    Jan 27, 2005
  3. Replies:
    5
    Views:
    19,615
  4. Jim Isaacson
    Replies:
    5
    Views:
    593
    Default User
    Nov 5, 2004
  5. Carcarius
    Replies:
    0
    Views:
    275
    Carcarius
    Dec 6, 2007
Loading...

Share This Page