Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

kp2a:

I just tried it out, and had a similar problem. Using the following code, I tried to connect to a local box:

#!/usr/bin/perl use strict; use warnings; use Net::Telnet; my @lines; my $t = new Net::Telnet( Timeout=>10, Prompt=>'/# $/', Dump_Log=>'NetTelnet_x.log' ); $t->open("192.168.4.190"); $t->login("foo", undef); @lines = $t->cmd("ls"); print @lines;

It was hanging on the login, as you described. When it finally timed out, I got the message:

timed-out waiting for password prompt at ./NetTelnet_x.pl line 13

Well, my local box doesn't have a password on the foo account[1], so it never prompts for password. I just changed the login line to read:

$t->cmd("foo");

and it started to work. Perhaps you have the same problem? (I notice that you don't quote the error message anywhere, so I can't tell. The one error message you *did* give was a match timeout from when you were playing with regular expressions.)

You might try logging in step by step with the cmd() function and verify that the login process is working as you expect. Then you can fix the login() call if you find a surprise.

...roboticus

Notes:

[1] I don't run Telnet servers (except for the few minutes for this test), so 733t h@X0r2[1] need not get their hopes up...

[1] Synonym for "script kiddie".


In reply to Re^3: Net::Telnet blocks by roboticus
in thread Net::Telnet blocks by kp2a

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-16 05:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found