[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-Modules] Net::Telnet



Greetings!

Just thought I'd poke my head up and tell you all how really chuffed I am 
at being able to write a Telnet client in 743 bytes of Perl code.  743!  
That's just *so* cool.

Henry.

---
use Net::Telnet();
$session = new Net::Telnet;

print "Hostname: ";
$host = <STDIN>;
chomp $host;

print "Port[23]: ";
$port = <STDIN>;
chomp $port;
if ($port eq '') { $port = 23; };

$session->open(Host,$host,Port,$port);

print "Username: ";
$user = <STDIN>;
chomp $user;

print "Password: ";
`stty raw`;
while (($char = getc()) ne "\n")
{
  if ($char =~ /\w/) { $pass .= $char; }
  elsif ($char eq "\b") { chop $pass; }
  else { sleep 1; }
}
`stty sane`;

$session->login(Name,$user,Password,$pass);

print "\n\nAccess Granted! (type 'quit' to quit the session)\n> ";
while(<STDIN>)
{
  last if (/quit/);
  @output = $session->cmd($_);
  pop @output; pop @output; print @output;
  print "> ";
}
print "Session closed.\n";
MacPerl::Quit(2);
---

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-modules-request@macperl.org