Evening, Monks.

I have a simple little script I've been working on that will post the private and public IPs for my machine to my website.

Everything in my script is working fine except for the 'put' command. It just hangs until I get a timeout, at which point my connection quits and the script ends. I am wondering if there is an error in my script, or if it is just my webserver. Or is there a better way to do this? My web host is 1and1, and my site is on a Linux server. TIA.

Here's the last bit of output to my shell:

Net::FTP=GLOB(0x82bce74)>>> STOR /private/myips Net::FTP=GLOB(0x82bce74): Timeout at myip.pl line 43 put failed at myip.pl line 43.

And, here's my code:

#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use HTTP::Request; use Net::FTP; $| = 1; print "Getting local ip...\n"; my $local_ip = qx/ifconfig eth0|grep -m 1 inet|awk {\'print \$2\'}|cut + -d \':\' -f2/; chomp($local_ip); print "Got local ip: $local_ip\n"; print "Getting remote ip...\n"; my $remote_ip; my $url = "http://www.whatismyip.com/"; my $ua=new LWP::UserAgent; my $request = new HTTP::Request('GET',$url); # create the http requ +est my $response=$ua->request($request); # perform the http request my $whatisipsite = $response->as_string(); # store the response a +s a string if ($whatisipsite =~ /(Your ip is )+(.*?)( WhatIsMyIP.com)/) { # pars +e out the IP address $remote_ip = $2; } chomp($remote_ip); print "Got remote ip: $remote_ip\n"; my $newipfound = 0; open (my $infile, "myips") or die "Can't open file $!"; while (<$infile>) { if (/$local_ip|$remote_ip/) { } else { $newipfound = 1; } } close $infile; if ($newipfound) { print "New ip found! Sending file to web site...\n"; open (my $outfile , ">myips") or die "Can't open file $!"; print $outfile "$local_ip\n$remote_ip\n"; close $outfile; my $ftp = Net::FTP->new("www.techfeed.net", Debug => 1); $ftp->login("*****",'*****'); $ftp->cwd("/private"); $ftp->ascii(); $ftp->put("myips","/private/myips") or die "put failed ", $ftp->me +ssage; $ftp->quit; print "File sent!\n"; }

In reply to FTP timeout by yacoubean

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.