This is a great program for all people running apache with dynamic IP - It gets your IP thru DOS's IPconfig (change that for the appropriate UNIX program), and places it in the httpd.conf overwriting your old IP, and starts apache. a few notes: A. This is made for my comp, as you'll see via the dirnames, etc. So: 1. Change the dir in the Open and System calls to reflect your dir. 2.Change the `ipconfig` to a UNIX console IP getting program and change the regex to reflect that. 3. BACK UP HTTPD.CONF! This is extremely important. 4. Check if your ServerName line in Httpd.conf is really number 256 (this is the default with an unchanged 1.3x Apache) UPDATE: Added a critical \n which will save your .conf file from getting funky. For all of those who've had their httpd.conf already ruined: echo $100 > /dev/null@yourhostname.net . Sorry.
#!/usr/bin/perl -w use strict; $_ = `ipconfig`; /(\d+\.\d+\.\d+\.\d+)\s*$/; my (@try); print "Starting apache service with $1 as IP...\n"; open(CONF, "C:\\progra~1\\apache~1\\apache\\conf\\httpd.conf") || die +"cannot open file: $!"; @try=<CONF>; close(CONF); print "$try[256] old IP"; $try[256]="ServerName $1\n"; #UPDATE HERE print "$try[256] is IP for apache"; open(CONF, ">C:\\progra~1\\apache~1\\apache\\conf\\httpd.conf") || die + "cannot open file3: $!"; foreach (@try) { print CONF "$_"; } close CONF; system("C:\\Progra~1\\Apache~1\\Apache\\Apache.exe") || die "Can't sta +rt apache service: $!";

In reply to Apache IP-Autoupdater by Nimster

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.