Hi ,
I am writing this code to telnet into windows machine.
The code works fine on the unix machine and runs the command 'ps -ef'. On W2K I am 
trying to telnet into the machine and to recognize the prompt 'C:\' . but it keeps on 
giving the error 'time-out. I have tried different combinations of the Regexp for the 
dos prompt but nothing seems to work. At certain expression it compiles but doesn't 
print.  
I tried the other way of using the "wait for" method (case2:)and use buffer. In that 
it is able to print what is in the buffer but not the exact output of the command. 
Say if you want to telnet to DOS machine and print the command 'dir' on that machine 
and see the output on your machine.

case 1:
my $hostname = '10.10.2.45';
my $prompt1 = '/\>$/';
my $name = 'administrator';
my $password = 'nn';
my $string = 'net start ';
my $session1 = Net::Telnet->new(Host => $hostname,) ; 
  $session1->login(Name => $name, Password => $password, Prompt => $prompt1,) 
  or print "2"; #login using username/pass. 
my @output = $session1->cmd(String => $string, Prompt => $prompt1,);#pass command  
print scalar "Command output: @output\n"; # resultant output is stored line by line in 
@output array. 
my @output1 = $session1->print('net start');
print "output1: @output1\n";
case 2:
my @before = $session1->waitfor('/successfully/');
print "before: @before\n";
$session1->close; 

Would appreciate if someone can help. 

thanks
N A

Reply via email to