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

hi monks,

when i am runing this program to connect to other system, i am getting the output only if the system is in Private IP, If the system is in Public Ip it is not displaying any output

what is the solution to connect and get the output for the public ip system

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

20040623 Edit by Corion: Added code tags, fixed linebreaks

Replies are listed 'Best First'.
Re: net::Telnet to connect public ip
by gri6507 (Deacon) on Jun 23, 2004 at 12:31 UTC
    Looking at your code, you don't seem to be checking for errors anywhere. Are you sure you actually successfully connect to the server (perhaps firewall issues)? Maybe this will shed more light on your problem.

    use Net::Telnet (); use strict; use warnings; my $t = new Net::Telnet (Timeout => 100, Prompt => '/[^ <-]\>/', Errmo +de => "return") ; $username = "administrator"; $passwd = ""; if (!$t->open("hostname")) { die "can't open: $!\n"; } if (!$t->login($username, $passwd)) { die "can't login: $!\n"; } @lines = $t->cmd("dir"); print @lines;
Re: net::Telnet to connect public ip
by ambrus (Abbot) on Jun 23, 2004 at 12:35 UTC

    Maybe it has nothing to do with public ip. Are you sure that Prompt => '/[^ <-]\>/' is correct? It looks wierd for me.

Re: net::Telnet to connect public ip
by iburrell (Chaplain) on Jun 23, 2004 at 16:27 UTC
    You aren't checking for errors so you don't know if you are successfully connecting.

    I am guessing that the client is inside the firewall and has its own private IP address. If that is the case, then it is quite possible that you can't connect to the public IP address. This happens most often when the router is using NAT to map the public IP address to the private IP address. From inside, this mapping does not happen.

      Hi Iburrell

      Thank You very much for your reply, your guessing is exactly right

      that the client is in private IP only where i am trying to connect to

      public IP to access some files

      actually there are some files in the Unix system which is given public IP

      to that, now i want to access those files from the Unix system to client

      system (Window O/S is installed in the client system and given Private IP)

      how can i able to solve this kindly help me

      Thanks in advance
        How is your network setup that the server only has a public IP address? That implies that you aren't using NAT, or the server is in a DMZ without NAT. In either case, the network should be configured to allow access from private IP addresses to the DMZ public IP addresses.

        One common solution is to use a split-horizon DNS. The internal DNS returns private IP address, and has record for purely internal hosts. The public DNS reutrns public IP addresses.

        Another solution for some protocols is to use a proxy. The proxy would be setup outside (or on the firewall) and connect back inside. This only works for some protocols (HTTP), and raises security issues about securing the proxy and the services from untrusted outside usage.