(See update below...)

I had some semi-serious issues with Webalizer. I'm using OS X, and it came with a nifty Perl install script. But it hosed my httpd.conf (it did, at least, make a backup). Check out the offending section (note that $t is input from a diamond operator):

if ($t =~ /^y/) { `cp /etc/httpd/httpd.conf /etc/httpd/httpd.conf.save`; $orig = 'CustomLog "\/private\/var\/log\/httpd\/access_log" common +'; $new = 'CustomLog "\/private\/var\/log\/httpd\/access_log" combine +d'; print "Modifying apache configuration..."; `/usr/bin/sed -e 's/$orig/\#$orig/' -e 's/\#$new/$new/' /etc/httpd +/httpd.conf > /etc/httpd/httpd.conf`; print " done. \n\nOriginal saved to /etc/httpd/httpd.conf.save\n\ +n"; print "Apache needs to be restarted for this to take effect, would + you like to do this now? (y/n) "; $a = <>; if ($a =~ /^y/) { print "Restarting apache..."; print " done\n\n"; } }
Note a few things. This script needs to be run as root (I did, via sudo). Backticks in void context, then a sed call (sed? From within Perl?!). I believe the sed call is what zeroed out my httpd.conf. Then, the part that I'm just fuming about. "Would you like to restart Apache?" I say yes. Script does nothing. "OK!"

It took me a little over a half hour to debug this. I didn't see any problems because I didn't have to reboot my machine until tonight (I originally installed Webalizer yesterday morning). And I only had to reboot tonight because I installed some other random program -- so I thought that the other program was the culprit (but it has nothing to do with Apache, which is why I was stumped).

All in all I really like the reports from Webalizer. But be warned if you install it with the OS X script. I'll be contacting the author with this information after this...

Update: I don't recall exactly which version of Webalizer had this malfunctioning script, but the latest seems to have addressed the problem. The script still has backticks in void context (so no error checking to see if the command failed) but at least it does actually perform the 'apachectl restart' when you tell it to. Just in case you were curious.


In reply to Re^2: Need a way to print script output to web page? by Nkuvu
in thread Need a way to print script output to web page? by Elijah

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.