Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Net::Telnet - cant able to connect from public IP to public IP

by sris (Initiate)
on Jun 24, 2004 at 11:30 UTC ( #369289=perlquestion: print w/replies, xml ) Need Help??
sris has asked for the wisdom of the Perl Monks concerning the following question:

hi monks,
i am trying to access some files from one system to another system where i gave public ip to both the systems, programatically(in perl) using Net::Telnet i am trying to connect to the other system but i am not able to connect can u kindly help me

the Following code which i am trying to execute

use Net::Telnet; my $t = new Net::Telnet (Timeout => 100, Prompt => '/[^ <-]\>/' +, Errmode => "return") ; $username = "administrator"; $passwd = ""; $t->open("hostname"); $t->login($username, $passwd); @lines = $t->cmd('dir'); print "\n @lines";

20040624 Edit by Corion: Fixed code tags

Replies are listed 'Best First'.
Re: Net::Telnet - cant able to connect from public IP to public IP
by Abigail-II (Bishop) on Jun 24, 2004 at 11:40 UTC
    The obvious question is, can you connect using a regular telnet client? If so, where does your connection with Net::Telnet go wrong? Does the connection succeed at the TCP/IP level? Does the other side issue a login/password prompt? Is your password correct? Is your regex for the prompt correct - it looks very suspicious to me, it matches lines where the second character is a >, and it's preceded by a character that isn't a space, a <, or a -? Do you get a timeout? Do you get an error message? Do you have Net::Telnet installed?

    Abigail

      hi Abigail-II

      Manually i can able to connect to that system but programatically

      i am not able to connect as i am having doubt in the prompt syntax

      my $t = new Net::Telnet (Timeout => 150, Prompt => '/^ <-\>/', Errmode => "return") ;

      in the above statement the syntax which i used for prompt is '/^ <-\>/'

      actually it is working properly for one system,

      but it is not working properly when i change the ip address in the coding

      i think you got it and kindly help me

      it is not displaying any errors also

        Different accounts may have different prompts, so if your regex is working for one system, that doesn't mean it should work for another system.

        If you can't give any details on where the process goes wrong, don't expect many useful answers from us. All we can do is guess - you might get lucky and someone will guess right. But having people have to guess isn't very efficient.

        Abigail

Re: Net::Telnet - cant able to connect from public IP to public IP
by gri6507 (Deacon) on Jun 24, 2004 at 12:46 UTC
    Did you try the suggestions from your earlier post 369017?
Re: Net::Telnet - cant able to connect from public IP to public IP
by jdavidboyd (Friar) on Jul 01, 2004 at 14:33 UTC
    turn on the output files, using dump_log, input_log, option_log, and output_log (read the docs to see how) and you can see what your script is going through as it attempts to connect.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://369289]
Approved by Corion
help
Chatterbox?
[ambrus]: Corion: really? Does that mean the Prima watcher objects behave as handles that stop the watcher when they're destroyed, just like AnyEvent expects?
[ambrus]: "all the bugs" -- hehe, good luck
[ambrus]: Corion: what I don't understand is, if you make a one-shot AnyEvent timer with short timeout, does this code guarantee that the Prima timer can't queue two timeout events before invoking any of them?
[ambrus]: Because that could break AnyEvent code, which is why I added a guard.
[ambrus]: (It might be easier to use the callback scalar as a guard, as in $c and &$c(); $c = ();)
[Corion]: ambrus: Hurr - yes, that might happen, as Prima will queue lots of stuff (Well, Windows will)
[Corion]: But I'm really amazed that it just took this little code (plus the idle handler I have in mind and something else dk suggested)

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2016-12-09 09:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (150 votes). Check out past polls.