You need to define a prompt for your session.  cmd is waiting until it sees 
what it thinks the prompt should be.  Since you have not defined it the 
default setting of '/[\$%#>] $/' is used, which it is not finding.  Here is 
a possible variation of your script:

use Net::Telnet;

$user="username";
$pass="password";
$host="hostname";

# Errmode is by default already set to die, so is not needed
$telnet = new Net::Telnet(Timeout=>4,
                           Prompt=>'c:');
$telnet->open($host);

# Since you use a normal login you can also change the next 5 lines to:
$telnet->login($user, $pass);

# cmd also includes the return so you don't need the \n
$line = $telnet->cmd("dir");
print $line;

I don't have net::telnet installed at home so I couldn't test it for errors, 
so I went from memory, hope it helps!

Kevin Pendleton

>From: "Eric Logeson" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Subject: net::telnet
>Date: Mon, 18 Feb 2002 09:44:43 -0500
>
>Hello,
>I am using the telnet server that comes with win2k. The authentication 
>level is set to "0" clear text. I can't seem to get the following script to 
>work, the script fails at line 10 with the following error message:
>"command timed-out at test.pl line 10"
>Has anybody been successful using net::telnet with win2k's built telnet 
>server?
>use Net::Telnet;
>$telnet = new Net::Telnet(Timeout=>4,
>                           Errmode=>'die');
>$telnet->open('testmachine.com');
>$telnet->waitfor('/login: $/i');
>$telnet->print('user');
>$telnet->waitfor('/password: $/i');
>$telnet->print('password');
>$telnet->waitfor(/"c:>\\"/);
>@lines = $telnet->cmd("dir\n");        #line 10
>print @lines;
>
>
>perl -v
>This is perl, v5.6.1 built for MSWin32-x86-multi-thread
>
>_________________
>Eric Logeson
>919-680-5679
>www.dukece.com
>
>




_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to