[Perl] Net::Telnet vers une machine win32

Net::Telnet vers une machine win32 [Perl] - Perl - Programmation

Marsh Posté le 05-03-2004 à 16:32:17    

je tente de passer une commande à une machine win32 et de récupérer l'output. Dans mon Inputfile, tout ce déroule à merveille, mais j'ai pourant rien dans mon array. Fonctionne sous unix en modifiant le nom de machine et le prompt
 

Code :
  1. my $telnet = new Net::Telnet ( Errmode    => 'return',
  2.                             Prompt     => '/C:\\\\/',
  3.                             Input_log  => 'input.log',
  4.                             Output_log => 'output.log',
  5.   );
  6.   if (! defined $telnet) {
  7.  die "Unable to create telnet object";
  8. }
  9.   $telnet->open("host" );
  10.   if (my $errmsg = $telnet->errmsg) {
  11.  die "Unable to open telnet $errmsg";
  12. }
  13.   $telnet->login("user", "pass" );
  14.   if (my $errmsg = $telnet->errmsg) {
  15.  die "Unable to login $errmsg";
  16. }
  17.  
  18.   my @lines =  $telnet->cmd("dir" );
  19.   if (my $errmsg = $telnet->errmsg) {
  20.  die "Unable to execute cmd $errmsg";
  21. }
  22.  
  23.   print @lines;

Reply

Marsh Posté le 05-03-2004 à 16:32:17   

Reply

Marsh Posté le 05-03-2004 à 16:32:54    

il faut que la machine ait un serveur telnet :/

Reply

Marsh Posté le 05-03-2004 à 16:46:57    

Taz a écrit :

il faut que la machine ait un serveur telnet :/


 
jfais un telnet sur la machine et ca fonctionne
 
dans mon input.log, j'ai bien mon résultat du dir
mais jai rien dans mon @lines

Reply

Marsh Posté le 05-03-2004 à 18:39:24    

up

Reply

Marsh Posté le 05-03-2004 à 19:00:25    

Réponse:
 
Connecting to a Remote MS-Windows Machine
By default MS-Windows doesn't come with a TELNET server. However third party TELNET servers are available. Unfortunately many of these servers falsely claim to be a TELNET server. This is especially true of the so-called "Microsoft Telnet Server" that comes installed with some newer versions MS-Windows.
 
When a TELNET server first accepts a connection, it must use the ASCII control characters carriage-return and line-feed to start a new line (see RFC854). A server like the "Microsoft Telnet Server" that doesn't do this, isn't a TELNET server. These servers send ANSI terminal escape sequences to position to a column on a subsequent line and to even position while writing characters that are adjacent to each other. Worse, when sending output these servers resend previously sent command output in a misguided attempt to display an entire terminal screen.
 
Connecting Net::Telnet to one of these false TELNET servers makes your job of parsing command output very difficult. It's better to replace a false TELNET server with a real TELNET server. The better TELNET servers for MS-Windows allow you to avoid the ANSI escapes by turning off something some of them call console mode.

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed