% telnet localhost 10023 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. .... login: #### #!/usr/bin/perl use warnings; use strict; use Net::Telnet; my ($username, $password) = @ARGV; die "usage $0 username password" unless $username && $password; my $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die', Port => 10023); $telnet->open('localhost'); $telnet->waitfor('/[\$#%:><][\s\b]+$/'); print "found login prompt..."; $telnet->print($username); $telnet->waitfor('/[\$#%:><][\s\b]+$/'); print "found password prompt..."; $telnet->print($password); print "logged in yay!\n";