Yes, his machine could very well have Telnet Server installed -- see below
-----Original Message----- From: R. Joseph Newton [mailto:[EMAIL PROTECTED] Sent: Monday, September 08, 2003 1:37 PM To: Nitin Aggarwal Cc: [EMAIL PROTECTED] Subject: Re: retrieve command data from DOS using telnet Nitin Aggarwal wrote: > 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 Does your Windows machine have a telnet server?!? I envy you, I guess. When I try reaching my laptop from my desktop via command line, I get: Greetings! E:\d_drive\perlStuff>telnet 192.168.0.97 Connecting To 192.168.0.97...Could not open a connection to host: Connect failed Unless you have a telnet server installed on the target machine, this may be the explanation. --------- [EMAIL PROTECTED] root]# telnet 192.168.1.6 Trying 192.168.1.6... Connected to 192.168.1.6 (192.168.1.6). Escape character is '^]'. Microsoft (R) Windows (TM) Version 5.00 (Build 2195) Welcome to Microsoft Telnet Service Telnet Server Build 5.00.99206.1 login: Adminstrator password: ************* *=============================================================== Welcome to Microsoft Telnet Server. *=============================================================== C:\>dir Volume in drive C has no label. Volume Serial Number is BCD1-771B Directory of C:\ 11/15/2002 03:52p <DIR> BUEXEC_INSTALL 11/12/2002 06:22p <DIR> compaq 11/12/2002 06:16p <DIR> CPQSYSTEM 04/07/2003 08:53p <DIR> Documents and Settings 11/12/2002 06:06p <DIR> Inetpub 06/05/2003 10:41a <DIR> mrtg 09/05/2003 12:06a <DIR> Program Files 11/12/2002 07:12p <DIR> spacks 08/29/2003 05:11p <DIR> sql2ksp3 08/06/2003 02:42p <DIR> temp 01/17/2003 02:37p <DIR> VERITAS 09/03/2003 06:58p <DIR> WINNT 09/03/2003 04:28p <DIR> ~wingrep.t 0 File(s) 0 bytes 13 Dir(s) 2,383,123,456 bytes free C:\> Yeah, his Win2K machine has Telnet Server. So does mine. But to access it from a non-NTLM-able OS you need to set NTLM to allow username and password to authenticate. For more information search for "Using Telnet Server" from START->Help. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]