#!/usr/bin/perl -w

use IO::Socket;
$remote = IO::Socket::INET->new(Proto=> "tcp",
				PeerAddr => "localhost",
				PeerPort => "8850",
				) or die "cannot connect to daytime port at localhost";
				
$username = $ARGV[0];
$password = $ARGV[1];

$line =  <$remote>;
chomp($line);
print "$line\n";

$line =  <$remote>;
#chomp($line);
#print "$line\n";

print $remote "$username\n";

$line =  <$remote>;
#chomp($line);
#print "$line\n";

print $remote "$password\n";

$line =  <$remote>;
chomp($line);
if ($line =~ m/^400:/)
{
	die "Invalid login\n";
}
elsif ($line =~ m/^200:/)
{
	print "Login ok\n";
}
else
{
	die "Invalid Response\n";
}


