This perl script can be used to upload IP addresses from a machine (windows, but easily enough linux, just change a few values) to a server via FTP. It's a quick and dirty fix, but it beats using other prefab programs... It runs in the background... It's my first USEFUL perl script, so don't be mean...
#!/usr/bin/perl -w #===================================================================== += # Author: Adam Bultman # Date: 27 October 2000 # Usage: This program runs a windows command (ipconfig), and pipes the + output # to a file. Once that is finished, it uploads the file to an f +tp # server. It then sleeps for 30 minutes, or a set time limit. +Then it # starts all over until interrupted. Swell! #===================================================================== +===== # Use the FTP module for Perl use Net::FTP; # Set some variables $time = 800; # Sleep for this many seconds $server = "server"; # Upload to this server $fileName = "file"; # Pipe to this file $userName = "userName"; # Set the user name... $password = "password"; # Terrible, but this is the password $cmd = "ipconfig |"; # Let's name the command #Let's assign an ftp connection... # Print out what the program does print "\nThis program will run \"ipconfig\" every $time seconds, pipe\ +n"; print "It to $fileName, and then upload the file to $server .\n"; for(;;) { # Open up the file and the command handle open (FILE, ">$fileName") || die "\nI couldn't open the file for o +verwriting. "; open (COMMAND, $cmd) || die "\nI couldn't run the program! "; # Try to print the results of the command to the file write_to_file; # Just for tying off loose ends close COMMAND || die " I couldn't close COMMAND "; close FILE || die " I couldn't close FILE"; $ftp = Net::FTP->new($server) || die "I couldn't open a connection + to $server "; # Log onto the server and put the file, then quit. $ftp->login($userName,$password); print "Logged in... "; $ftp->cwd('public_html'); print "Changed dir to public_html... "; $ftp->put($fileName); print "I put the file... "; $ftp->quit(); print "Logging out...\n"; print "I put the file $fileName to $server successfully.\n"; # Sleep the alloted time. $| = 1; sleep($time); } sub html_header { $document_title = $_[0]; print FILE "<HTTP_END"; print FILE "Content-type: text/html"; print FILE "<html>"; print FILE "<head>"; print FILE "<title>$document_title</title>"; print FILE "</head>"; print FILE "<body>"; print FILE "<center><h1>$document_title</h1></center>"; print FILE "<pre>"; } sub write_to_file { html_header("MY IP ADDRESS"); print FILE <COMMAND>; print FILE "</pre>"; print FILE "<hr>"; print FILE "</body>"; print FILE "</html>"; }

In reply to Slick way to upload dynamic IP addresses by adam_bultman

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.