Hi All:
Sorry to be sending this to both Win32-Admin and Win32-users but trying to solicit
advice from as many parties as possible. Also, apologies for this being so long.
My problem: Differences in the operation of the Win2K Telnet Server (included with
Win2K) and the Telnet server form the WindozeNT Resource Kit(note, a patch from MS is
required for the telnet.inf file to install this properly).
I am using the 'waitfor' method at the moment as I have been having problems with the
cmd method on Win2K (why this is becomes clear later in the discussion).
Here is my test script, dead simple(line numbers are for explanation purposes):
1 use Net::Telnet;
2 use strict;
3 use warnings;
4
5 my $destination = "srecept";
6 my $telnet = new Net::Telnet ( Timeout=>10, Prompt=> '/\\>$/i');
7 my $time = localtime();
8 $telnet -> dump_log("dump.txt");
9 $telnet -> input_log("input.txt");
10
11 $telnet->open($destination);
12 #$telnet->waitfor('/login: $/i'); # Used for Win2K log on.
13 $telnet->waitfor('/Username: $/i'); #Used for NT log on.
14 $telnet->print('Administrator');
15 $telnet->waitfor('/Password: $/i');
16 $telnet->print('12345');
17 $telnet->waitfor('/\>/i');
18 print("We have received the prompt, we are in\n");
19 $time = localtime();
20 print("Sending now at $time\n");
21 $telnet->print('now');
22 print("Waiting for the prompt\n");
23 my ($prematch, $match) =$telnet->waitfor('/C:/i');
24 print("The characters before the $match were:\n");
25 print("$prematch\n");
26 $time = localtime();
27 print("finished at $time\n");
Now, this script works perfect using the NT RK Telnet server. This is the output:
*D:\Perl\practice\examples\Telnet>perl telnetoff7.pl
*We have received the prompt, we are in
*Sending now at Thu Nov 28 09:44:36 2002
*Waiting for the prompt
*The characters before the C: were:
*now
*
*Thu Nov 28 09:39:48 2002
*
*
*finished at Thu Nov 28 09:44:36 2002
*
*D:\Perl\practice\examples\Telnet>
Exactly as one would expect. Now here is the command line output from the script
running to a Win2K telnet server:
*D:\Perl\practice\examples\Telnet>perl telnetoff7.pl
*We have received the prompt, we are in
*Sending now at Thu Nov 28 09:43:05 2002
*Waiting for the prompt
*The characters before the C: were:
*
?[5;1H?[K?[6;1H?[K?[7;1H
*?[K?[8;1H?[K?[9;1H?[K?[10;1H?[K?[11;1H?[K?[12;1H?[K?[13;1H?[K?[14;1H?[K?[15;1H?[K?[16;1H?[K?[17;1H?[
*K?[18;1H?[K?[19;1H?[K?[20;1H?[K?[21;1H?[K?[22;1H?[K?[23;1H?[K?[24;1H?[K?[25;1H?[K?[4;5H?[4;5Hnow?[6;
*1HThu Nov 28 09:35:53 2002?[8;1H
*finished at Thu Nov 28 09:43:05 2002
*
*D:\Perl\practice\examples\Telnet>perl telnetoff7.pl
As you can see, loads of gibberish. Obviously, at this stage of the game one looks at
the dump_log and input_log files....and here is where it gets interesting. Here is the
dump_log file from NT, the telnet server that works with Net::Telnet as expected:
< 0x00000: 0a 0d 0a 0d 0a .....
< 0x00000: 45 43 48 4f 20 69 73 20 6f 66 66 2e 0d 0a ECHO is off...
< 0x00000: 57 65 6c 63 6f 6d 65 20 74 6f 20 74 68 65 20 54 Welcome to the T
< 0x00010: 65 6c 6e 65 74 20 53 65 72 76 69 63 65 20 42 65 elnet Service Be
< 0x00020: 74 61 2e 20 20 54 68 69 73 20 73 65 72 76 69 63 ta. This servic
< 0x00030: 65 20 69 73 20 73 74 69 6c 6c 20 61 0d 0a 77 6f e is still a..wo
< 0x00040: 72 6b 20 69 6e 20 70 72 6f 67 72 65 73 73 2e 20 rk in progress.
< 0x00050: 20 50 6c 65 61 73 65 20 63 68 65 63 6b 20 74 68 Please check th
< 0x00060: 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 66 74 70 20 e following ftp
< 0x00070: 6c 6f 63 61 74 69 6f 6e 20 66 6f 72 0d 0a 74 68 location for..th
< 0x00080: 65 20 6d 6f 73 74 20 63 75 72 72 65 6e 74 20 76 e most current v
< 0x00090: 65 72 73 69 6f 6e 20 6f 66 20 74 68 69 73 20 74 ersion of this t
< 0x000a0: 6f 6f 6c 3a 0d 0a 45 43 48 4f 20 69 73 20 6f 66 ool:..ECHO is of
< 0x000b0: 66 2e 0d 0a 20 20 20 20 66 74 70 20 6e 74 72 6b f... ftp ntrk
< 0x000c0: 2e 6d 69 63 72 6f 73 6f 66 74 2e 63 6f 6d 5c 74 .microsoft.com\t
< 0x000d0: 65 6c 6e 65 74 64 5c 0d 0a 45 43 48 4f 20 69 73 elnetd\..ECHO is
< 0x000e0: 20 6f 66 66 2e 0d 0a 54 6f 20 72 65 70 6f 72 74 off...To report
< 0x000f0: 20 62 75 67 73 20 6f 72 20 72 65 71 75 65 73 74 bugs or request
< 0x00100: 20 6d 6f 72 65 20 54 65 6c 6e 65 74 64 20 69 6e more Telnetd in
< 0x00110: 66 6f 72 6d 61 74 69 6f 6e 20 70 6c 65 61 73 65 formation please
< 0x00120: 20 65 6d 61 69 6c 0d 0a 6d 65 20 61 74 20 74 65 email..me at te
< 0x00130: 6c 6e 65 74 64 40 6e 74 72 6b 2e 6d 69 63 72 6f [EMAIL PROTECTED]
< 0x00140: 73 6f 66 74 2e 63 6f 6d 2e 0d 0a 45 43 48 4f 20 soft.com...ECHO
< 0x00150: 69 73 20 6f 66 66 2e 0d 0a 43 3a 5c 57 49 4e 4e is off...C:\WINN
< 0x00160: 54 5c 73 79 73 74 65 6d 33 32 3e T\system32>
> 0x00000: 6e 6f 77 0d 0a now..
< 0x00000: 6e n
< 0x00000: 6f 77 0d 0a ow..
< 0x00000: 0d 0a 54 68 75 20 4e 6f 76 20 32 38 20 30 39 3a ..Thu Nov 28 09:
< 0x00010: 33 39 3a 34 38 20 32 30 30 32 0d 0a 39:48 2002..
< 0x00000: 0d 0a 43 3a 5c 57 49 4e 4e 54 5c 73 79 73 74 65 ..C:\WINNT\syste
< 0x00010: 6d 33 32 3e m32>
No drama here. But now look at the Win2K dump_log:
< 0x00000: ff fb 01 ff fd 03 ff fd 1f ff fd 00 ff fb 00 4d ��.��.��.��.��.M
< 0x00010: 69 63 72 6f 73 6f 66 74 20 28 52 29 20 57 69 6e icrosoft (R) Win
< 0x00020: 64 6f 77 73 20 28 54 4d 29 20 56 65 72 73 69 6f dows (TM) Versio
< 0x00030: 6e 20 35 2e 30 30 20 28 42 75 69 6c 64 20 32 31 n 5.00 (Build 21
< 0x00040: 39 35 29 0d 0a 57 65 6c 63 6f 6d 65 20 74 6f 20 95)..Welcome to
< 0x00050: 4d 69 63 72 6f 73 6f 66 74 20 54 65 6c 6e 65 74 Microsoft Telnet
< 0x00060: 20 53 65 72 76 69 63 65 20 0d 0a 54 65 6c 6e 65 Service ..Telne
< 0x00070: 74 20 53 65 72 76 65 72 20 42 75 69 6c 64 20 35 t Server Build 5
< 0x00080: 2e 30 30 2e 39 39 32 30 31 2e 31 0a 0d 6c 6f 67 .00.99201.1..log
< 0x00090: 69 6e 3a 20 in:
> 0x00000: ff fd 01 ff fc 03 ff fc 1f ff fc 00 ff fe 00 ��.��.��.��.��.
> 0x00000: 41 64 6d 69 6e 69 73 74 72 61 74 6f 72 0d 0a Administrator..
< 0x00000: 41 64 6d 69 6e 69 73 74 72 61 74 6f 72 0a 0d 70 Administrator..p
< 0x00010: 61 73 73 77 6f 72 64 3a 20 assword:
> 0x00000: 31 32 33 34 35 0d 0a 12345..
< 0x00000: 2a 2a 2a 2a 2a ff fd 18 *****��.
> 0x00000: ff fc 18 ��.
< 0x00000: 1b 5b 31 3b 31 48 2a 3d 3d 3d 3d 3d 3d 3d 3d 3d .[1;1H*=========
< 0x00010: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
< 0x00020: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
< 0x00030: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
< 0x00040: 3d 3d 3d 3d 3d 3d 20 20 20 20 20 20 20 20 20 20 ======
< 0x00050: 20 20 20 20 20 20 1b 5b 32 3b 31 48 57 65 6c 63 .[2;1HWelc
< 0x00060: 6f 6d 65 20 74 6f 20 4d 69 63 72 6f 73 6f 66 74 ome to Microsoft
< 0x00070: 20 54 65 6c 6e 65 74 20 53 65 72 76 65 72 2e 20 Telnet Server.
< 0x00080: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
< 0x00090: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
< 0x000a0: 20 20 20 20 20 20 20 20 20 20 20 20 1b 5b 33 3b .[3;
< 0x000b0: 31 48 2a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 1H*=============
< 0x000c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
< 0x000d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
< 0x000e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
< 0x000f0: 3d 3d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ==
< 0x00100: 20 20 1b 5b 34 3b 31 48 43 3a 5c 3e 20 20 20 20 .[4;1HC:\>
< 0x00110: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
< 0x00120: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
< 0x00130: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
< 0x00140: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
< 0x00150: 20 20 20 20 20 20 20 20 1b 5b 35 3b 31 48 1b 5b .[5;1H.[
< 0x00160: 4b 1b 5b 36 3b 31 48 1b 5b 4b 1b 5b 37 3b 31 48 K.[6;1H.[K.[7;1H
< 0x00170: 1b 5b 4b 1b 5b 38 3b 31 48 1b 5b 4b 1b 5b 39 3b .[K.[8;1H.[K.[9;
< 0x00180: 31 48 1b 5b 4b 1b 5b 31 30 3b 31 48 1b 5b 4b 1b 1H.[K.[10;1H.[K.
< 0x00190: 5b 31 31 3b 31 48 1b 5b 4b 1b 5b 31 32 3b 31 48 [11;1H.[K.[12;1H
< 0x001a0: 1b 5b 4b 1b 5b 31 33 3b 31 48 1b 5b 4b 1b 5b 31 .[K.[13;1H.[K.[1
< 0x001b0: 34 3b 31 48 1b 5b 4b 1b 5b 31 35 3b 31 48 1b 5b 4;1H.[K.[15;1H.[
< 0x001c0: 4b 1b 5b 31 36 3b 31 48 1b 5b 4b 1b 5b 31 37 3b K.[16;1H.[K.[17;
< 0x001d0: 31 48 1b 5b 4b 1b 5b 31 38 3b 31 48 1b 5b 4b 1b 1H.[K.[18;1H.[K.
< 0x001e0: 5b 31 39 3b 31 48 1b 5b 4b 1b 5b 32 30 3b 31 48 [19;1H.[K.[20;1H
< 0x001f0: 1b 5b 4b 1b 5b 32 31 3b 31 48 1b 5b 4b 1b 5b 32 .[K.[21;1H.[K.[2
< 0x00200: 32 3b 31 48 1b 5b 4b 1b 5b 32 33 3b 31 48 1b 5b 2;1H.[K.[23;1H.[
< 0x00210: 4b 1b 5b 32 34 3b 31 48 1b 5b 4b 1b 5b 32 35 3b K.[24;1H.[K.[25;
< 0x00220: 31 48 1b 5b 4b 1b 5b 34 3b 35 48 1H.[K.[4;5H
> 0x00000: 6e 6f 77 0d 0a now..
< 0x00000: 1b 5b 34 3b 35 48 6e 6f 77 1b 5b 36 3b 31 48 54 .[4;5Hnow.[6;1HT
< 0x00010: 68 75 20 4e 6f 76 20 32 38 20 30 39 3a 33 35 3a hu Nov 28 09:35:
< 0x00020: 35 33 20 32 30 30 32 1b 5b 38 3b 31 48 43 3a 5c 53 2002.[8;1HC:\
< 0x00030: 3e 1b 5b 38 3b 35 48 >.[8;5H
Now, there is no point at looking at the input_log from the working session(THE ntrk
SERVER) but the input_log file form the Win2K session is interesting:
*Welcome to Microsoft Telnet Service
*Telnet Server Build 5.00.99201.1
*
*login: Administrator
*
*password: *****[1;1H*===============================================================
[2;1HWelcome to Microsoft Telnet Server.
[3;1H*===============================================================
[4;1HC:\>
[5;1H[K[6;1H[K[7;1H[K[8;1H[K[9;1H[K[10;1H[K[11;1H[K[12;1H[K[13;1H[K[14;1H[K[15;1H[K[16;1H[K[17;1H[K[18;1H[K[19;1H[K[20;1H[K[21;1H[K[22;1H[K[23;1H[K[24;1H[K[25;1H[K[4;5H[4;5Hnow[6;1HThu
Nov 28 09:35:53 2002[8;1HC:\>[8;5H
Notice that the 'password' line has no CRLF at the end nor is there any CRLF from
there to tend of the session. Somehow, Net::Telnet cannot parse the output from Win2K
properly and from the dump_log, the Win2K telnet server is outputting stuff that looks
VERY different from the NTRK Telnet server. Also, I have run this against a Cisco
Router, using an appropriate Cisco IOS command of course, and it works just like the
NTRK telnet server.
So, my question is to any Telnet server expert out there:
What are the differences in the telnet servers on Win2K and NTRK?
How can I tweak Net::Telnet to work with the Win2K telnet server?
Cheers,
John
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs