Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Reduce timeout

- Reduce the timeout
- Wait for a string we know will show up
- After seeing Username: we should type in 'admin', the username
#!/usr/bin/perl
use strict;
use warnings;

use Net::Telnet;

my $port = 8000;
my $hostname = 'localhost';

my $telnet = Net::Telnet->new(
                        Port      => $port,
                        Host      => $hostname,
                        Timeout   => 1,
                    );
print "opened\n";

{
    my ($prematch, $match) = $telnet->waitfor('/Username:.*$/');
    if ($prematch =~ /Welcome/) {
        print "welcome printed\n";
    }
    $telnet->print('admin');
}

print "after wait\n";

  • Manually check out what does this server do?

  • Turn the two example clients scripts into test using Test::More.

  • Continue and write more tests for this telnet server.

  • write a test that makes sure when someone types in 'help' the system does not write invalid command

  • make sure you can write a test that can handle cases such as the '??'