CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate: Re: [tprizler] Trying to connect using Net::Telnet: Edit Log


Jul 30, 2008, 6:25 AM

Views: 1026
Re: [tprizler] Trying to connect using Net::Telnet

In Reply To
Hi, Found the problem!


my $Dump = "/Dump.txt";
my $Input = "/Input.txt";

my $telnet = new Net::Telnet ( Timeout=>10,Port => 2034 ,
Dump_Log => $Dump,
Input_log => $Input,
Prompt => '/login: $/i'); <--------------- This line was unnecessary.

Second, i found out that in order to initialize a connection i must use the "Errmode=>""" The thing is that from some reason when I write Errmode=>'die' the connaction fails, and when I write it as "Errmode=>'return'" , the connecion works and I can axecute commands as i wish! Now I have the problem to distinguish between to kinds of prompts: 1. login: 2. [~]# What I worte is :

my $telnet = new Net::Telnet ( Timeout=>10,
Port => 2034 ,

if ($telnet->waitfor('/login:.*$/')) {
$telnet->waitfor('/password: $/i');
$telnet->waitfor('/\# $/i');
my @lines = $telnet->cmd('who');
print @lines;

elsif ($telnet->waitfor('/\# $/i')) {
my @lines = $telnet->cmd('who');
print @lines;


From debugging it a little I dicovered that The If fails.. Is there a right way to do this distinction??? Thanks!!!!

(This post was edited by tprizler on Jul 30, 2008, 6:27 AM)

Edit Log:
Post edited by tprizler (Novice) on Jul 30, 2008, 6:26 AM
Post edited by tprizler (Novice) on Jul 30, 2008, 6:27 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives