use Net::Telnet; # initialize the telnet module my $username = 'user'; my $password = 'some_password'; my $command = 'ls -la'; print "enter the full domain name or IP of the machine that you want to telnet to\n"; chomp(my $host=); my prompt_regex = '/ .* ( \-?\@? \w*?\s? [\$#\%>~] \]? | \\\[\\e\[0m\\\] \[0m ) \s? /x'; $shell = new Net::Telnet ('Timeout'=>'7', 'Errmode'=> sub { report_error("login failure"); }, 'Prompt' => $prompt_regex ); $shell->open(Host=>$host); # opens the object $shell->login($username,$password); # login # then we issue some command with $shell->cmd("$command"); # or get the output of some command my $cmd_output = $shell->cmd("$command"); # and close the telnet object sleep 1; $shell->close; sub report_error { .... some code here to handle errors.... }