Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Windows Net::Telnet problem

by djkumar72 (Initiate)
on Jul 05, 2005 at 05:20 UTC ( [id://472356]=perlquestion: print w/replies, xml ) Need Help??

djkumar72 has asked for the wisdom of the Perl Monks concerning the following question:

I could Telnet from my windows workstation, but the following code throws "eof read waiting for login prompt:"
use Net::Telnet (); $telnet = new Net::Telnet(Timeout=>20,Prompt => '/[\$%#>] $/'); $telnet->open("machine"); $telnet->login("username","password"); print "Logged into the system \n";
if i use waifor('/login: ?$/i') after "open" it throws  read error: An operation was attempted on something that is not a socket. I am struck with this issue, please help me!

Edited by Arunbear: Changed title from 'Help!', as per Monastery guidelines

Replies are listed 'Best First'.
Re: Windows Net::Telnet problem
by polettix (Vicar) on Jul 05, 2005 at 08:11 UTC
    The info you provide seem too few for us to be able to help you (but I may be wrong). Reading the docs for Net::Telnet, I see that there is a Debugging section which suggests to enable input_log and debug_log - did you try them? What was the result?

    Moreover, you should check the result of your open call here. From the docs:

    Time-outs don't work for this method on machines that don't implement SIGALRM - most notably MS-Windows machines. For those machines, an error is returned when the system reaches its own time-out while trying to connect.
    If your open does not succeed, you keep going with the login method, but the server is likely to have closed the TCP connection, and Net::Telnet gets an EOF back when reading from the socket.

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.
      you may be right. i tried to debug with dump_log and input_log but they are creating only empty files but not writing any thing. Is there any other way i connect to unix machine from windows? Thanks, Jay
Re: Windows Net::Telnet problem
by chas (Priest) on Jul 05, 2005 at 12:25 UTC
    I've generally found it a bit tricky to get Net::Telnet working properly for particular machines. Something close to the following usually works for me (but seemingly inconsequential changes can cause failure):
    use strict; use Net::Telnet; print "passwd: "; my $passwd=<>; chomp($passwd); #passwd not hard-coded in script my $telnet = Net::Telnet->new(Host=>'linux63.blahblah.edu',Prompt=>'/l +inux63> $ /'); $telnet->waitfor('/login/'); $telnet->print("myusername"); $telnet->waitfor('/Password/'); $telnet->print("$passwd\n"); $telnet->waitfor('/linux63/'); my @lines = $telnet->cmd("somecommand"); #etc $telnet->print("logout\n");

    chas

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://472356]
Approved by cLive ;-)
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-16 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found