Got the session, but can't get through the login.

Posted on 2008-11-07
Last Modified: 2012-05-05
Manual telnet would produce:

User Access Verification


When I use the code below, I only get:

User Access Verification

(Can't get to the password prompt.)

use warnings;

use strict;

use Net::Telnet;


my $Response;


my $telnet = Net::Telnet->new();


  or die "Could not open connection\n";


while ($Response = $telnet->getline){

        print $Response;


Open in new window

Question by:HilltownHealthCenter

    Author Comment

    More: after several seconds, this line appeared:

    read timed-out at C:\ line 13

    LVL 39

    Accepted Solution

    The getline function will return the next line, and if one isn't available, it'll wait for one (or until it times out).  A line ends with "\n" (but this can be changed).  Since the password line doesn't have a "\n" on the end, it isn't yet a full line, so the getline function doesn't return it.

    It sounds like you might want to use the waitfor function instead of getline:

    You might want to read through the Net::Telnet documentation, as there are a lot of features of this module
    my $telnet = Net::Telnet->new();
      or die "Could not open connection\n";

    Open in new window


    Author Closing Comment

    Got it to work. Fantastic!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
    There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now