<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">
<channel>
    <title>freebsd.munk.me.uk - Perl</title>
    <link>http://freebsd.munk.me.uk/</link>
    <description>FreeBSD System Administration</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.2 - http://www.s9y.org/</generator>
    
    <image>
        <url>http://freebsd.munk.me.uk/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: freebsd.munk.me.uk - Perl - FreeBSD System Administration</title>
        <link>http://freebsd.munk.me.uk/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Command Line Web Browsing With WWW::Mechanize::Shell</title>
    <link>http://freebsd.munk.me.uk/archives/179-Command-Line-Web-Browsing-With-WWWMechanizeShell.html</link>
            <category>Perl</category>
            <category>Ports</category>
            <category>Shell</category>
    
    <comments>http://freebsd.munk.me.uk/archives/179-Command-Line-Web-Browsing-With-WWWMechanizeShell.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=179</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=179</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    &lt;span style=&quot;font-weight:bold&quot;&gt;Introduction&lt;/span&gt;&lt;br /&gt;
The perl module &lt;a href=&quot;http://search.cpan.org/~corion/WWW-Mechanize-Shell/&quot;  title=&quot;WWW::Mechanize::Shell On CPAN&quot;&gt;WWW::Mechanize::Shell&lt;/a&gt; is a brilliant tool for browsing websites at a very low level - think somewhere in between using telnet and using a command line based browser like lynx or links or w3m and you&#039;ll be close.  WWW::Mechanize::Shell is more than that though, it allows you to script a complete HTTP session so it can be replayed back at a later date without any interaction using WWW::Mechanize::Shell&#039;s parent perl module WWW::Mechanize - great for automatically submitting HTML forms/ POST data regularly via a cron job for example.&lt;br /&gt;
&lt;br /&gt;
In this article I&#039;ll be talking about installing WWW::Mechanize::Shell, look at a typical WWW::Mechanize::Shell browsing session and look at some examples of how I use WWW::Mechanize::Shell to make things easier.  Finally the article will end with a real world example - using mechshell to automate logging into FreshPorts and updating a watch list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Installing WWW::Mechanize::Shell&lt;/span&gt;&lt;br /&gt;
As the name suggests, WWW::Mechanize::Shell is a perl module whose &#039;parent&#039; is the &lt;a href=&quot;http://search.cpan.org/~petdance/WWW-Mechanize/&quot;  title=&quot;WWW::Mechanize at CPAN&quot;&gt;WWW::Mechanize&lt;/a&gt; module written by Andy Lester (WWW::Mechanize::Shell itself is written by Max Maischein at time of original writing).  WWW::Mechanize does all the work in the background - WWW::Mechanize::Shell just makes it easy to interact in a HTTP session.  WWW::Mechanize::Shell and all it&#039;s dependencies can be installed from the ports tree:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/root#&amp;#160;cd&amp;#160;/usr/ports/www/p5-WWW-Mechanize-Shell/&lt;br /&gt;
root@users&amp;#160;/home/munk/ports/www/p5-WWW-Mechanize-Shell#&amp;#160;make&amp;#160;install&lt;br /&gt;
root@users&amp;#160;/home/munk/ports/www/p5-WWW-Mechanize-Shell#&amp;#160;rehash&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Getting Started Using WWW::Mechanize::Shell&lt;/span&gt;&lt;br /&gt;
Once installed, start up the WWW::Mechanize::Shell using the following you can use the following commandline:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/root#&amp;#160;perl&amp;#160;-MWWW&amp;#58;&amp;#58;Mechanize&amp;#58;&amp;#58;Shell&amp;#160;-eshell&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
To make things easier though I use a CSH shell alias which aliases &#039;mechshell&#039; to the command above:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;root@users&amp;#160;/root#&amp;#160;grep&amp;#160;mechshell&amp;#160;$cshrc&lt;br /&gt;
alias&amp;#160;mechshell&amp;#160;perl&amp;#160;-MWWW&amp;#58;&amp;#58;Mechanize&amp;#58;&amp;#58;Shell&amp;#160;-eshell&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Examples of WWW::Mechanize Usage&lt;/span&gt;&lt;br /&gt;
I usually use WWW::Mechanize when I want to manipulate data from websites that require a stateful HTTP session - ie a browsing session where there&#039;s more than one URL you have to visit to complete the &#039;session&#039;.  Usually these kind of stateful sessions involve logging into the website first, then browsing to another page to obtain the data and then I have the WWW::Mechanize perl script handle the data and return any results on the commandline.&lt;br /&gt;
&lt;br /&gt;
Some examples of scripts that I&#039;ve use WWW::Mechanize with:&lt;br /&gt;
&lt;br /&gt;
eclipse_flex_speed.pl&lt;br /&gt;
My ISP (Eclipse UK) used to allow you to &#039;flex&#039; your internet speed from 256k up to 2Mbps.  They ran an offer for a while where you could flex to the max for 3 months - unfortunately you could only flex for 12 hours at a time, which meant logging into the control panel every 12hrs, selecting the maximum speed and then submitting the form.  PITA basically.&lt;br /&gt;
&lt;br /&gt;
Instead I wrote eclipse_flex_speed.pl to automatically login to the Eclipse control panel, &#039;click&#039; the 2Mbps radio button and then submit the form so my speed got flexed automagically.  I then added the script as a cron job to autorun every 12hours, saving the haslle of doing it all manually!&lt;br /&gt;
&lt;br /&gt;
aod_get.pl&lt;br /&gt;
The BBC website allows you to listen to streams of all BBC radio broadcasts for up to a week after they&#039;ve been aired live.  The problem is that the web interface you listen to the stream on in your web browser only allows you to skip 5 or 15 minutes ahead in time and doesn&#039;t allow you to go to specific times in the stream.  To get around this you can obtain the URL of the real player stream and open it in a standalone real player - doing this you can go to any point in the stream easily.  Trouble is finding the URL of the stream isn&#039;t that easy and involves viewing the source HTML of the web UI and copy/pasting a partial URL.&lt;br /&gt;
&lt;br /&gt;
I started to write a WWW::Mechanize script to automate the &#039;screen scraping&#039; of all the available feeds from the BBC Audio On Demand site and listing them on one single HTML page linking the name of the feed to the real player feed URL.  As it goes though, someone else - Dave Cross - already had the same idea and wrote &lt;a href=&quot;http://blog.dave.org.uk/archives/000652.html&quot;&gt;a great script for scraping the BBC feeds&lt;/a&gt; automatically.  I now run this in a cronjob once a week.&lt;br /&gt;
&lt;br /&gt;
torrentflux_ctl.pl&lt;br /&gt;
This is a script for starting and stopping all torrents under the control of the torrentflux web based bittorrent client.  The script logs in as the torrent owner and then stops or starts all the torrents for that user - basically just does a GET of a URL that causes torrentflux to stop or start all torrents.  Crude but effective.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight:bold&quot;&gt;Real world example - Automating the update of FreshPorts watch list&lt;/span&gt;&lt;br /&gt;
Below is a real world example usage of WWW::Mechanize::Shell - automating the procedure of updating your watch list on &lt;a href=&quot;http://www.freshports.org/about.php&quot;  title=&quot;About FreshPorts&quot;&gt;Freshports.org&lt;/a&gt;.  I&#039;ve included comments as &#039;# this is a comment&#039; to help explain what each command is doing.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#&amp;#160;Start&amp;#160;up&amp;#160;mechshell&amp;#160;-&amp;#160;alias&amp;#160;for&amp;#160;&#039;perl&amp;#160;-MWWW&amp;#58;&amp;#58;Mechanize&amp;#58;&amp;#58;Shell&amp;#160;-eshell&#039;&amp;#58;&lt;br /&gt;
munk@users&amp;#160;/home/munk#&amp;#160;mechshell&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Request&amp;#160;the&amp;#160;URL&amp;#160;http&amp;#58;//www.freshports.org/login.php.&lt;br /&gt;
#&amp;#160;Note&amp;#160;the&amp;#160;HTTP&amp;#160;response&amp;#160;&#039;&amp;#40;200&amp;#41;&#039;&amp;#160;is&amp;#160;displayed&amp;#160;underneath&lt;br /&gt;
#&amp;#160;to&amp;#160;indicate&amp;#160;the&amp;#160;page&amp;#160;was&amp;#160;fetched&amp;#160;successfully&amp;#58;&lt;br /&gt;
&amp;#40;no&amp;#160;url&amp;#41;&amp;#62;get&amp;#160;http&amp;#58;//www.freshports.org/login.php&lt;br /&gt;
Retrieving&amp;#160;http&amp;#58;//www.freshports.org/login.php&amp;#40;200&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Use&amp;#160;the&amp;#160;mechshell&amp;#160;&#039;dump&#039;&amp;#160;command&amp;#160;to&amp;#160;dump&amp;#160;the&amp;#160;contents&lt;br /&gt;
#&amp;#160;of&amp;#160;all&amp;#160;forms&amp;#160;found&amp;#160;on&amp;#160;the&amp;#160;login&amp;#160;page&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/login.php&amp;#62;dump&lt;br /&gt;
POST&amp;#160;http&amp;#58;//www.freshports.org/login.php?origin=%2F&amp;#160;&amp;#91;l&amp;#93;&lt;br /&gt;
&amp;#160;&amp;#160;custom_settings=1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;hidden&amp;#160;readonly&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;LOGIN=1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;hidden&amp;#160;readonly&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;UserID=&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;text&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;Password=&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;password&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;submit=Login&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;submit&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#60;NONAME&amp;#62;=&amp;#60;UNDEF&amp;#62;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;reset&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;There&#039;s&amp;#160;just&amp;#160;a&amp;#160;single&amp;#160;form&amp;#160;on&amp;#160;this&amp;#160;page&amp;#58;&lt;br /&gt;
#&amp;#160;-&amp;#160;the&amp;#160;form&#039;s&amp;#160;&#039;ACTION&#039;&amp;#160;is&amp;#160;set&amp;#160;to&amp;#160;submit&amp;#160;the&amp;#160;form&amp;#160;using&amp;#160;the&amp;#160;POST&amp;#160;method&lt;br /&gt;
#&amp;#160;&amp;#160;&amp;#160;to&amp;#160;the&amp;#160;url&amp;#160;http&amp;#58;//www.freshports.org/login.php?origin=%2F&lt;br /&gt;
#&amp;#160;The&amp;#160;form&amp;#160;contains&amp;#160;the&amp;#160;following&amp;#160;form&amp;#160;fields&amp;#58;&lt;br /&gt;
#&amp;#160;-&amp;#160;2&amp;#160;hidden&amp;#160;fields&lt;br /&gt;
#&amp;#160;-&amp;#160;1&amp;#160;text&amp;#160;field&amp;#160;called&amp;#160;&#039;UserID&#039;&lt;br /&gt;
#&amp;#160;-&amp;#160;1&amp;#160;password&amp;#160;field&amp;#160;called&amp;#160;&#039;Password&#039;&lt;br /&gt;
#&amp;#160;-&amp;#160;1&amp;#160;submit&amp;#160;field&amp;#160;called&amp;#160;&#039;Login&#039;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Fill&amp;#160;in&amp;#160;the&amp;#160;&#039;UserID&#039;&amp;#160;and&amp;#160;&#039;Password&#039;&amp;#160;fields&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/login.php&amp;#62;value&amp;#160;UserID&amp;#160;munk&lt;br /&gt;
http&amp;#58;//www.freshports.org/login.php&amp;#62;value&amp;#160;Password&amp;#160;xxxxxx&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;And&amp;#160;then&amp;#160;submit&amp;#160;the&amp;#160;form.&amp;#160;&amp;#160;Note&amp;#160;we&amp;#160;can&amp;#160;just&amp;#160;use&amp;#160;the&amp;#160;mechshell&amp;#160;&#039;submit&#039;&lt;br /&gt;
#&amp;#160;command&amp;#160;here&amp;#160;because&amp;#160;there&amp;#160;is&amp;#160;only&amp;#160;a&amp;#160;single&amp;#160;form&amp;#160;on&amp;#160;the&amp;#160;page.&amp;#160;&amp;#160;If&amp;#160;there&amp;#160;were&lt;br /&gt;
#&amp;#160;more&amp;#160;than&amp;#160;one&amp;#160;form&amp;#160;on&amp;#160;the&amp;#160;page&amp;#160;we&amp;#160;would&amp;#160;need&amp;#160;to&amp;#160;specify&amp;#160;which&amp;#160;button&amp;#160;exactly&amp;#160;to&lt;br /&gt;
#&amp;#160;click&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/login.php&amp;#62;submit&lt;br /&gt;
200&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Again&amp;#160;note&amp;#160;that&amp;#160;the&amp;#160;&#039;200&#039;&amp;#160;response&amp;#160;indicates&amp;#160;the&amp;#160;request&amp;#160;was&amp;#160;successful.&lt;br /&gt;
#&amp;#160;Also&amp;#160;note&amp;#160;that&amp;#160;the&amp;#160;next&amp;#160;mechshell&amp;#160;prompt&amp;#160;below&amp;#160;has&amp;#160;changed&amp;#160;from&lt;br /&gt;
#&amp;#160;&#039;http&amp;#58;//www.freshports.org/login.php&amp;#62;&#039;&amp;#160;to&amp;#160;just&amp;#160;&#039;http&amp;#58;//www.freshports.org/&#039;&amp;#160;-&lt;br /&gt;
#&amp;#160;this&amp;#160;indicates&amp;#160;that&amp;#160;the&amp;#160;login&amp;#160;script&amp;#160;has&amp;#160;probably&amp;#160;redirected&amp;#160;us&amp;#160;to&amp;#160;the&lt;br /&gt;
#&amp;#160;freshports&amp;#160;home&amp;#160;page.&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Now&amp;#160;we&amp;#160;take&amp;#160;a&amp;#160;look&amp;#160;to&amp;#160;check&amp;#160;that&amp;#160;the&amp;#160;login&amp;#160;succeeded&amp;#160;ok.&amp;#160;&amp;#160;To&amp;#160;do&amp;#160;this&amp;#160;we&amp;#160;use&lt;br /&gt;
#&amp;#160;the&amp;#160;mechshell&amp;#160;&#039;content&#039;&amp;#160;command&amp;#160;which&amp;#160;effectively&amp;#160;dumps&amp;#160;the&amp;#160;content&amp;#160;of&amp;#160;the&lt;br /&gt;
#&amp;#160;returned&amp;#160;page&amp;#160;back&amp;#160;at&amp;#160;us&amp;#160;in&amp;#160;a&amp;#160;pager.&lt;br /&gt;
#&amp;#160;What&amp;#160;we&#039;re&amp;#160;looking&amp;#160;for&amp;#160;is&amp;#160;the&amp;#160;text&amp;#160;&#039;Logged&amp;#160;in&amp;#160;as&amp;#160;munk&#039;&amp;#160;which&amp;#160;will&amp;#160;indicate&amp;#160;we&lt;br /&gt;
#&amp;#160;logged&amp;#160;in&amp;#160;ok&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/&amp;#62;content&lt;br /&gt;
&amp;#60;!DOCTYPE&amp;#160;HTML&amp;#160;PUBLIC&amp;#160;&quot;-//W3C//DTD&amp;#160;HTML&amp;#160;4.01&amp;#160;Transitional//EN&quot;&amp;#62;&lt;br /&gt;
&amp;#60;HTML&amp;#62;&lt;br /&gt;
&amp;#60;HEAD&amp;#62;&lt;br /&gt;
-snip-&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;td&amp;#160;NOWRAP&amp;#62;&amp;#60;FONT&amp;#160;SIZE=&quot;-1&quot;&amp;#62;Logged&amp;#160;in&amp;#160;as&amp;#160;munk&amp;#60;/FONT&amp;#62;&amp;#60;br&amp;#62;&amp;#60;FONT&amp;#160;SIZE=&quot;-1&quot;&amp;#62;&amp;#60;a&amp;#160;href=&quot;http://freebsd.munk.me.uk/customize.php?origin=%2F&quot;&amp;#160;title=&quot;Customize&amp;#160;your&amp;#160;settings&quot;&amp;#62;Customize&amp;#60;/a&lt;br /&gt;
&amp;#62;&amp;#60;/FONT&amp;#62;&amp;#60;br&amp;#62;&amp;#60;FONT&amp;#160;SIZE=&quot;-1&quot;&amp;#62;&amp;#60;a&amp;#160;href=&quot;http://freebsd.munk.me.uk/logout.php&quot;&amp;#160;title=&quot;Logout&amp;#160;of&amp;#160;the&amp;#160;website&quot;&amp;#62;Logout&amp;#60;/a&amp;#62;&amp;#60;/FONT&amp;#62;&amp;#60;br&amp;#62;&amp;#60;FONT&amp;#160;SIZE=&quot;-1&quot;&amp;#62;&amp;#60;a&amp;#160;href=&quot;/my-flagged-commits.php&quot;&amp;#160;title=&quot;Li&lt;br /&gt;
st&amp;#160;of&amp;#160;commits&amp;#160;you&amp;#160;have&amp;#160;flagged&quot;&amp;#62;My&amp;#160;Flagged&amp;#160;Commits&amp;#60;/a&amp;#62;&amp;#60;/FONT&amp;#62;&amp;#60;br&amp;#62;&lt;br /&gt;
-snip-&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Now&amp;#160;we&#039;re&amp;#160;logged&amp;#160;in&amp;#160;ok&amp;#160;we&amp;#160;can&amp;#160;continue&amp;#160;to&amp;#160;upload&amp;#160;the&amp;#160;mypkg_info.txt&amp;#160;file&amp;#160;we&lt;br /&gt;
#&amp;#160;created&amp;#160;earlier.&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;First&amp;#160;browse&amp;#160;to&amp;#160;the&amp;#160;pkg_upload.php&amp;#160;page&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/&amp;#62;get&amp;#160;http&amp;#58;//www.freshports.org/pkg_upload.php&lt;br /&gt;
Retrieving&amp;#160;http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#40;200&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Now&amp;#160;use&amp;#160;&#039;dump&#039;&amp;#160;to&amp;#160;see&amp;#160;a&amp;#160;list&amp;#160;of&amp;#160;form&amp;#160;fields&amp;#160;on&amp;#160;this&amp;#160;page.&lt;br /&gt;
#&amp;#160;Note&amp;#160;that&amp;#160;there&amp;#160;are&amp;#160;2&amp;#160;submit&amp;#160;buttons&amp;#160;on&amp;#160;this&amp;#160;page&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#62;dump&lt;br /&gt;
POST&amp;#160;http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#160;&amp;#40;multipart/form-data&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;pkg_info=&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;file&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;staging=Staging&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;submit&amp;#41;&lt;br /&gt;
&amp;#160;&amp;#160;wlid=5393&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;option&amp;#41;&amp;#160;&amp;#160;&amp;#160;&amp;#91;&amp;#42;5393/main&amp;#42;&amp;#93;&lt;br /&gt;
&amp;#160;&amp;#160;replaceappend=replace&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;radio&amp;#41;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#91;&amp;#42;replace/Replace&amp;#160;list&amp;#160;contents|append/Append&amp;#160;to&amp;#160;list&amp;#160;&amp;#40;duplicates&amp;#160;will&amp;#160;be&amp;#160;removed&amp;#41;&amp;#93;&lt;br /&gt;
&amp;#160;&amp;#160;upload=Upload&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#40;submit&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;We&amp;#160;need&amp;#160;to&amp;#160;fill&amp;#160;out&amp;#160;the&amp;#160;form&amp;#160;here.&amp;#160;&amp;#160;Uploading&amp;#160;files&amp;#160;with&amp;#160;mechshell&amp;#160;is&amp;#160;as&lt;br /&gt;
#&amp;#160;simple&amp;#160;as&amp;#160;completing&amp;#160;the&amp;#160;correct&amp;#160;file&amp;#160;type&amp;#160;field&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#62;value&amp;#160;pkg_info&amp;#160;/tmp/mypkg_info.txt&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Ok,&amp;#160;now&amp;#160;we&#039;re&amp;#160;ready&amp;#160;to&amp;#160;submit&amp;#160;the&amp;#160;form.&lt;br /&gt;
#&amp;#160;Note&amp;#160;that&amp;#160;because&amp;#160;there&amp;#160;are&amp;#160;2&amp;#160;submit&amp;#160;buttons&amp;#160;on&amp;#160;this&amp;#160;form,&amp;#160;we&amp;#160;must&amp;#160;explicitly&lt;br /&gt;
#&amp;#160;tell&amp;#160;mechshell&amp;#160;which&amp;#160;button&amp;#160;it&amp;#160;is&amp;#160;that&amp;#160;we&amp;#160;want&amp;#160;to&amp;#160;click&amp;#160;on&amp;#160;-&amp;#160;to&amp;#160;do&amp;#160;that&amp;#160;we&amp;#160;use&lt;br /&gt;
#&amp;#160;the&amp;#160;&#039;click&#039;&amp;#160;command.&amp;#160;&amp;#160;Just&amp;#160;using&amp;#160;&#039;submit&#039;&amp;#160;here&amp;#160;would&amp;#160;possibly&amp;#160;click&amp;#160;on&amp;#160;the&lt;br /&gt;
#&amp;#160;&#039;staging&#039;&amp;#160;button&amp;#160;which&amp;#160;is&amp;#160;not&amp;#160;what&amp;#160;we&amp;#160;want&amp;#160;-&amp;#160;instead&amp;#160;we&amp;#160;use&amp;#160;the&amp;#160;command&lt;br /&gt;
#&amp;#160;&#039;click&amp;#160;upload&#039;&amp;#160;to&amp;#160;indicate&amp;#160;we&amp;#160;want&amp;#160;to&amp;#160;click&amp;#160;on&amp;#160;the&amp;#160;&#039;upload&#039;&amp;#160;button&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#62;click&amp;#160;upload&lt;br /&gt;
&amp;#40;200&amp;#41;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Success!&amp;#160;&amp;#160;It&#039;s&amp;#160;a&amp;#160;good&amp;#160;idea&amp;#160;now&amp;#160;to&amp;#160;just&amp;#160;check&amp;#160;that&amp;#160;this&amp;#160;worked&amp;#160;by&amp;#160;browsing&amp;#160;in&lt;br /&gt;
#&amp;#160;a&amp;#160;web&amp;#160;browser&amp;#160;to&amp;#160;your&amp;#160;watch&amp;#160;list&amp;#160;and&amp;#160;checking&amp;#160;the&amp;#160;new&amp;#160;items&amp;#160;were&amp;#160;updated&amp;#160;ok&amp;#160;&amp;#40;of&lt;br /&gt;
#&amp;#160;course&amp;#160;you&amp;#160;can&amp;#160;do&amp;#160;this&amp;#160;in&amp;#160;mechshell&amp;#160;if&amp;#160;you&amp;#160;want&amp;#160;but&amp;#160;I&#039;ll&amp;#160;leave&amp;#160;that&amp;#160;out&amp;#160;here!&amp;#41;.&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Finally,&amp;#160;the&amp;#160;really&amp;#160;cool&amp;#160;bit.&amp;#160;&amp;#160;The&amp;#160;mechshell&amp;#160;&#039;script&#039;&amp;#160;command&amp;#160;will&amp;#160;dump&amp;#160;out&lt;br /&gt;
#&amp;#160;the&amp;#160;perl&amp;#160;code&amp;#160;required&amp;#160;to&amp;#160;perform&amp;#160;all&amp;#160;of&amp;#160;the&amp;#160;above&amp;#160;actions&amp;#160;again&amp;#160;if&amp;#160;you&amp;#160;copy&lt;br /&gt;
#&amp;#160;them&amp;#160;into&amp;#160;a&amp;#160;perl&amp;#160;script&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#62;script&lt;br /&gt;
#!perl&amp;#160;-w&lt;br /&gt;
use&amp;#160;strict;&lt;br /&gt;
use&amp;#160;WWW&amp;#58;&amp;#58;Mechanize;&lt;br /&gt;
use&amp;#160;WWW&amp;#58;&amp;#58;Mechanize&amp;#58;&amp;#58;FormFiller;&lt;br /&gt;
use&amp;#160;URI&amp;#58;&amp;#58;URL;&lt;br /&gt;
-snip-&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Also,&amp;#160;if&amp;#160;you&amp;#160;provide&amp;#160;a&amp;#160;filename&amp;#160;as&amp;#160;an&amp;#160;argument&amp;#160;to&amp;#160;the&amp;#160;&#039;script&#039;&amp;#160;command,&lt;br /&gt;
#&amp;#160;mechshell&amp;#160;will&amp;#160;dump&amp;#160;all&amp;#160;the&amp;#160;script&amp;#160;commands&amp;#160;to&amp;#160;that&amp;#160;filename&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#62;script&amp;#160;/tmp/freshports_update.pl&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Finally,&amp;#160;use&amp;#160;&#039;quit&#039;&amp;#160;to&amp;#160;exit&amp;#160;the&amp;#160;mechshell&amp;#58;&lt;br /&gt;
http&amp;#58;//www.freshports.org/pkg_upload.php&amp;#62;quit&lt;br /&gt;
munk@users&amp;#160;/home/munk#&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Now all that remains is to open up /tmp/freshports_update.pl and tidy the script up so that it&#039;s more suitable for automated use via cron.  For example, any &#039;dump&#039; and &#039;content&#039; commands can be taken out - these would only cause problems anyway if run from a non-interactive shell as used by cron.&lt;br /&gt;
&lt;br /&gt;
We also need to add some code to have the script dump the contents of &#039;pkg_info -qoa&#039; to a temporary file prior to uploading.&lt;br /&gt;
&lt;br /&gt;
The completed &#039;quick and dirty&#039; hack looks like this then:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/bin/perl&amp;#160;-w&lt;br /&gt;
use&amp;#160;strict;&lt;br /&gt;
use&amp;#160;WWW&amp;#58;&amp;#58;Mechanize;&lt;br /&gt;
use&amp;#160;WWW&amp;#58;&amp;#58;Mechanize&amp;#58;&amp;#58;FormFiller;&lt;br /&gt;
use&amp;#160;URI&amp;#58;&amp;#58;URL;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;FreshPorts&amp;#160;username/pass&amp;#58;&lt;br /&gt;
my&amp;#160;$user=&quot;munk&quot;;&lt;br /&gt;
my&amp;#160;$pass=&quot;xxxxx&quot;;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Temp&amp;#160;location&amp;#160;to&amp;#160;store&amp;#160;output&amp;#160;from&amp;#160;&#039;pkg_info&amp;#160;-qoa&#039;&amp;#58;&lt;br /&gt;
my&amp;#160;$mypkg_info=&quot;/tmp/freshports/mypkg_info.txt&quot;;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;prepare&amp;#160;file&amp;#160;containing&amp;#160;output&amp;#160;from&amp;#58;&amp;#160;pkg_info&amp;#160;-qoa&lt;br /&gt;
`pkg_info&amp;#160;-qoa&amp;#160;&amp;#62;&amp;#160;$mypkg_info`;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Prepare&amp;#160;WWW&amp;#58;&amp;#58;Mechanize&amp;#58;&lt;br /&gt;
my&amp;#160;$agent&amp;#160;=&amp;#160;WWW&amp;#58;&amp;#58;Mechanize-&amp;#62;new&amp;#40;&amp;#160;autocheck&amp;#160;=&amp;#62;&amp;#160;1&amp;#160;&amp;#41;;&lt;br /&gt;
my&amp;#160;$formfiller&amp;#160;=&amp;#160;WWW&amp;#58;&amp;#58;Mechanize&amp;#58;&amp;#58;FormFiller-&amp;#62;new&amp;#40;&amp;#41;;&lt;br /&gt;
$agent-&amp;#62;env_proxy&amp;#40;&amp;#41;;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Login&amp;#160;to&amp;#160;FreshPorts&amp;#58;&lt;br /&gt;
$agent-&amp;#62;get&amp;#40;&#039;http&amp;#58;//www.freshports.org/login.php&#039;&amp;#41;;&lt;br /&gt;
$agent-&amp;#62;form_number&amp;#40;1&amp;#41;&amp;#160;if&amp;#160;$agent-&amp;#62;forms&amp;#160;and&amp;#160;scalar&amp;#160;@{$agent-&amp;#62;forms};&lt;br /&gt;
{&amp;#160;local&amp;#160;$^W;&amp;#160;$agent-&amp;#62;current_form-&amp;#62;value&amp;#40;&#039;UserID&#039;,&amp;#160;$user&amp;#41;;&amp;#160;};&lt;br /&gt;
{&amp;#160;local&amp;#160;$^W;&amp;#160;$agent-&amp;#62;current_form-&amp;#62;value&amp;#40;&#039;Password&#039;,&amp;#160;$pass&amp;#41;;&amp;#160;};&lt;br /&gt;
$agent-&amp;#62;submit&amp;#40;&amp;#41;;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Submit&amp;#160;pkg_info&amp;#160;details&amp;#160;to&amp;#160;FreshPorts&amp;#160;pkg_upload&amp;#160;page&amp;#58;&lt;br /&gt;
$agent-&amp;#62;get&amp;#40;&#039;http&amp;#58;//www.freshports.org/pkg_upload.php&#039;&amp;#41;;&lt;br /&gt;
$agent-&amp;#62;form_number&amp;#40;1&amp;#41;&amp;#160;if&amp;#160;$agent-&amp;#62;forms&amp;#160;and&amp;#160;scalar&amp;#160;@{$agent-&amp;#62;forms};&lt;br /&gt;
{&amp;#160;local&amp;#160;$^W;&amp;#160;$agent-&amp;#62;current_form-&amp;#62;value&amp;#40;&#039;pkg_info&#039;,&amp;#160;$mypkg_info&amp;#41;;&amp;#160;};&lt;br /&gt;
$agent-&amp;#62;click&amp;#40;&#039;upload&#039;&amp;#41;;&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Remove&amp;#160;temporary&amp;#160;file&amp;#58;&lt;br /&gt;
`rm&amp;#160;$mypkg_info`;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
After saving the script and making the file executable, an entry can then be added to cron to have the script auto update the list of ports at freshports once a week - or however often you require it to be updated, once a week is more than enough for me.  Sorted! :) 
    </content:encoded>

    <pubDate>Wed, 15 Aug 2007 12:46:00 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/179-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Portupgrade fails to upgrade dependencies</title>
    <link>http://freebsd.munk.me.uk/archives/199-Portupgrade-fails-to-upgrade-dependencies.html</link>
            <category>Perl</category>
            <category>Ports</category>
    
    <comments>http://freebsd.munk.me.uk/archives/199-Portupgrade-fails-to-upgrade-dependencies.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=199</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=199</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    When using portupgrade to upgrade ports recursively, occasionally you get a problem where portupgrade fails to upgrade a dependency of a port that&#039;s being upgraded.    This seems to happen most often with perl ports - p5-* ports - probably because perl packages/ports use the most dependencies of all with being modular in design anyway.&lt;br /&gt;
&lt;br /&gt;
An example is when I just went to run the weekly &#039;portupgrade -arR&#039; and whilst upgrading p5-PathTools-3.21, portupgrade found that another port - p5-Scalar-List-Utils-1.18 - also needed upgrading.  Unfortunately the upgrade of that port failed with the following error:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;===&amp;#62;&amp;#160;&amp;#160;Checking&amp;#160;if&amp;#160;lang/p5-Scalar-List-Utils&amp;#160;already&amp;#160;installed&lt;br /&gt;
===&amp;#62;&amp;#160;&amp;#160;&amp;#160;p5-Scalar-List-Utils-1.18,1&amp;#160;is&amp;#160;already&amp;#160;installed&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;You&amp;#160;may&amp;#160;wish&amp;#160;to&amp;#160;``make&amp;#160;deinstall&#039;&#039;&amp;#160;and&amp;#160;install&amp;#160;this&amp;#160;port&amp;#160;again&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;by&amp;#160;``make&amp;#160;reinstall&#039;&#039;&amp;#160;to&amp;#160;upgrade&amp;#160;it&amp;#160;properly.&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;If&amp;#160;you&amp;#160;really&amp;#160;wish&amp;#160;to&amp;#160;overwrite&amp;#160;the&amp;#160;old&amp;#160;port&amp;#160;of&amp;#160;lang/p5-Scalar-List-Utils&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;without&amp;#160;deleting&amp;#160;it&amp;#160;first,&amp;#160;set&amp;#160;the&amp;#160;variable&amp;#160;&quot;FORCE_PKG_REGISTER&quot;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;in&amp;#160;your&amp;#160;environment&amp;#160;or&amp;#160;the&amp;#160;&quot;make&amp;#160;install&quot;&amp;#160;command&amp;#160;line.&lt;br /&gt;
&amp;#42;&amp;#42;&amp;#42;&amp;#160;Error&amp;#160;code&amp;#160;1&lt;br /&gt;
&lt;br /&gt;
Stop&amp;#160;in&amp;#160;/home/munk/ports/lang/p5-Scalar-List-Utils.&lt;br /&gt;
&amp;#42;&amp;#42;&amp;#42;&amp;#160;Error&amp;#160;code&amp;#160;1&lt;br /&gt;
&lt;br /&gt;
Stop&amp;#160;in&amp;#160;/home/munk/ports/devel/p5-PathTools.&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
The problem is that any already installed dependencies - regardless of whether they need upgrading or not - are seen by portupgrade as being installed already and so it refuses to upgrade.  Hence if the port you&#039;re trying to upgrade has a dependency that *also* needs upgrading, this will fail.  Adding &#039;-f&#039; onto the portupgrade line makes no difference.&lt;br /&gt;
&lt;br /&gt;
One solution is to set the environment variable &#039;FORCE_PKG_REGISTER&#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;setenv&amp;#160;FORCE_PKG_REGISTER&amp;#160;1&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
and then run the portupgrade command again.  The installed status of the dependencies are then effectively ignored and the port dependencies are forcibly installed.  Not sure why portupgrade doesn&#039;t upgrade any dependencies automatically - I would have thought any dependencies of a port would be automatically checked for upgrades and upgraded if necessary.  Maybe I&#039;m missing something. 
    </content:encoded>

    <pubDate>Sun, 24 Dec 2006 15:01:00 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/199-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Solving permission problems with parsepath.pl</title>
    <link>http://freebsd.munk.me.uk/archives/175-Solving-permission-problems-with-parsepath.pl.html</link>
            <category>Apache</category>
            <category>FreeBSD</category>
            <category>General</category>
            <category>Perl</category>
            <category>PHP</category>
            <category>Security</category>
            <category>Shell</category>
            <category>SSH</category>
    
    <comments>http://freebsd.munk.me.uk/archives/175-Solving-permission-problems-with-parsepath.pl.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=175</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=175</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    &lt;a href=&quot;http://sial.org/howto/debug/unix/parsepath&quot;  title=&quot;parsepath.pl - a script for solving file permission problems&quot;&gt;parsepath.pl&lt;/a&gt; is a brilliant perl script for fixing permissions problems on Unix based platforms by &lt;a href=&quot;http://sial.org/&quot;  title=&quot;Jeremy Mates&quot;&gt;Jeremy Mates&lt;/a&gt;.   Probably the most common type of permission problem from a sysadmin/webmaster&#039;s viewpoint is uploading a file to a directory in a website&#039;s document root folder and then trying to access the file or script in a web browser only to get the dreaded 403 error message:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;Forbidden&lt;br /&gt;
You don&#039;t have permission to access /foo/bar/test.php on this server.&lt;br /&gt;
&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Most time the solution is very simple, just change the permissions on &#039;test.php&#039; to make sure the user the webserver runs as can read the file correctly - the simplest and most common method being to change the mode of the file to &#039;755&#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;chmod&amp;#160;755&amp;#160;test.php&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately sometimes it&#039;s not that easy and many times you see users asking &#039;I&#039;m getting &#039;access denied&#039; errors even though I&#039;ve changed the perms to 755&#039;.  The problem is that one of the subdirectories that the &#039;test.php&#039; file lives in has permissions set so that the webserver can&#039;t read the file properly.  Now that&#039;s where the headache comes in :)&lt;br /&gt;
&lt;br /&gt;
However, &lt;a href=&quot;http://sial.org/howto/debug/unix/parsepath&quot;  title=&quot;parsepath.pl - a script for solving file permission problems&quot;&gt;parsepath.pl&lt;/a&gt; can take the headache out of fixing permissions problems.&lt;br /&gt;
&lt;br /&gt;
Say you have a website document root directory tree /usr/local/www/web/www.munk.me.uk/foo/bar and you upload a web script &#039;test.php&#039; into that directory.  You try and access the file in a webbrowser but get the 403 permission denied error above.  First off you check the permissions on the file itself:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#91;23&amp;#58;58&amp;#58;17&amp;#93;&amp;#160;root@users&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar#&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;;&amp;#160;ls&amp;#160;-l&lt;br /&gt;
total&amp;#160;0&lt;br /&gt;
-rwxr-xr-x&amp;#160;&amp;#160;1&amp;#160;www&amp;#160;www&amp;#160;&amp;#160;0&amp;#160;Sep&amp;#160;&amp;#160;4&amp;#160;23&amp;#58;39&amp;#160;test.php&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
That looks ok, with permissions 755 and the owner/group set to &#039;www&#039; the webserver user &#039;www&#039; should be able to read the file ok.  So in this case the problem must be with the permissions on one of the parent subdirectories.  The old method of working out the perms would be either to trawl one by one through each directory checking the perms on each subdirectory or to change the permissions recursively on the document root folder so all subfolders have the read bit set for the webserver user/group.&lt;br /&gt;
&lt;br /&gt;
With parsepath.pl things are a lot simpler though - just run the following command:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#91;0&amp;#58;03&amp;#58;21&amp;#93;&amp;#160;root@users&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar#&amp;#160;parsepath.pl&amp;#160;user=www&amp;#160;+r&amp;#160;test.php&lt;br /&gt;
!&amp;#160;group=www&amp;#160;+rx&amp;#160;fails&amp;#58;&amp;#160;d&amp;#160;0700&amp;#160;root&amp;#58;www&amp;#160;/usr/local/www/web/www.munk.me.uk/foo&lt;br /&gt;
!&amp;#160;unix-other&amp;#160;+rx&amp;#160;fails&amp;#58;&amp;#160;d&amp;#160;0750&amp;#160;root&amp;#58;wheel&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
With this command parsepath.pl  recurses through each subdirectory below the file/path you feed it on the commandline and tells you the permissions problems - if any - for the user &#039;www&#039; (the user=www argument) to read (the +r argument) the file &#039;test.php&#039;.&lt;br /&gt;
&lt;br /&gt;
In the output, we&#039;re told that permissions to read the test.php by the user www fails on two counts:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#&amp;#160;the&amp;#160;group&amp;#160;bit&amp;#160;on&amp;#160;the&amp;#160;folder&amp;#160;&#039;foo&#039;&amp;#160;doesn&#039;t&amp;#160;have&amp;#160;the&amp;#160;+rx&amp;#160;flag&amp;#160;set&amp;#58;&lt;br /&gt;
!&amp;#160;group=www&amp;#160;+rx&amp;#160;fails&amp;#58;&amp;#160;d&amp;#160;0700&amp;#160;root&amp;#58;www&amp;#160;/usr/local/www/web/www.munk.me.uk/foo&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;the&amp;#160;other&amp;#160;bit&amp;#160;on&amp;#160;the&amp;#160;folder&amp;#160;&#039;bar&#039;&amp;#160;doesn&#039;t&amp;#160;have&amp;#160;the&amp;#160;+rx&amp;#160;flag&amp;#160;set&amp;#58;&lt;br /&gt;
!&amp;#160;unix-other&amp;#160;+rx&amp;#160;fails&amp;#58;&amp;#160;d&amp;#160;0750&amp;#160;root&amp;#58;wheel&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
With this information it&#039;s easy enough to go in and make the changes necessary to fix the problem using &#039;chmod g+rx foo foo/bar&#039;.&lt;br /&gt;
&lt;br /&gt;
There are other ways of invoking parsepath.pl though.  Running it just with a file/path as an argument it&#039;ll tell you the permissions on each subdirectory under it:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#91;0&amp;#58;10&amp;#58;33&amp;#93;&amp;#160;root@users&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar#&amp;#160;&lt;br /&gt;
&amp;#62;&amp;#160;parsepath.pl&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar/test.php&lt;br /&gt;
%&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar/test.php&lt;br /&gt;
d&amp;#160;0755&amp;#160;root&amp;#58;wheel&amp;#160;/&lt;br /&gt;
d&amp;#160;0755&amp;#160;root&amp;#58;wheel&amp;#160;/usr&lt;br /&gt;
d&amp;#160;0755&amp;#160;root&amp;#58;wheel&amp;#160;/usr/local&lt;br /&gt;
d&amp;#160;0755&amp;#160;root&amp;#58;wheel&amp;#160;/usr/local/www&lt;br /&gt;
d&amp;#160;0770&amp;#160;www&amp;#58;wheel&amp;#160;/usr/local/www/web&lt;br /&gt;
d&amp;#160;0750&amp;#160;www&amp;#58;www&amp;#160;/usr/local/www/web/www.munk.me.uk&lt;br /&gt;
d&amp;#160;0700&amp;#160;root&amp;#58;www&amp;#160;/usr/local/www/web/www.munk.me.uk/foo&lt;br /&gt;
d&amp;#160;0750&amp;#160;root&amp;#58;wheel&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar&lt;br /&gt;
f&amp;#160;0755&amp;#160;root&amp;#58;www&amp;#160;/usr/local/www/web/www.munk.me.uk/foo/bar/test.php&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
which can is better to see a whole tree in one go.  &lt;br /&gt;
&lt;br /&gt;
No permissions were harmed in the making of this article!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I&#039;ll include the parsepath.pl script in the extended article just in case the original ever gets lost - big credit of course goes to the author of the script, &lt;a href=&quot;http://sial.org/&quot;  title=&quot;Jeremy Mates&quot;&gt;Jeremy Mates&lt;/a&gt;.  His site is actually very interesting from a sysadmin&#039;s point of view containing lots of interesting admin scripts and thoughts on system administration in general - spent quite a while grazing through his stuff there - cheers Jeremy.&lt;br /&gt;
 &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/175-Solving-permission-problems-with-parsepath.pl.html#extended&quot;&gt;Continue reading &quot;Solving permission problems with parsepath.pl&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 04 Sep 2006 22:41:00 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/175-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Serendipity Spam Statistics</title>
    <link>http://freebsd.munk.me.uk/archives/170-Serendipity-Spam-Statistics.html</link>
            <category>ipfilter</category>
            <category>Perl</category>
            <category>Serendipity</category>
            <category>Spam</category>
    
    <comments>http://freebsd.munk.me.uk/archives/170-Serendipity-Spam-Statistics.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=170</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=170</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    I just downloaded this great looking &lt;a href=&quot;andreas.id.au/blog/archives/77-Akismet-Spam-Statistics.html&quot;  title=&quot;Spam Statistics Plugin&quot;&gt;spam statistics plugin for Serendipity from Andreas&lt;/a&gt;.  Unfortunately after installing it it didn&#039;t seem to work, so I got stuck in to see what was up.&lt;br /&gt;
&lt;br /&gt;
Turns out it only works when the &lt;a href=&quot;http://blog.s9y.org/archives/123-Spamblock-Improvements,-Part-II.html&quot;  title=&quot;Serendipity Spamblock Plugin&quot;&gt;spamblock plugin&lt;/a&gt; logs to the database, so I&#039;ll either look into making it work with log files or maybe think about adding something to the admin stats plugin if that&#039;s possible.  Or do neither given it&#039;s not uber important to me given I get a raft of info on the spam stats each night via a cron job.&lt;br /&gt;
&lt;br /&gt;
I have a cron job that checks various things spam related on a daily basis - checking for referer spam, quarantined files uploaded via PHP, mod_security log entries that need attention and finally checking for serendipity / weblog spam.  The situation with weblog spam had gotten so bad on the old domain munk.nu that I even ended up creating a script to convert spamblock log entries into firewall rules for ipf.  I&#039;m not kidding, at least 100 trackback spam entries per day through June and July - for the year 2006 so far there are nearly 9000 unique IPs dropping new trackback spam.&lt;br /&gt;
&lt;br /&gt;
What&#039;s annoying too is that even adding offending IPs to my firewall block list, each and every new day there would be another 100 new unique IP addresses spamming the blog.  No doubt this is a botnet - 100 new zombies found per day sounds like a professional organisation.&lt;br /&gt;
&lt;br /&gt;
Ho hum.  Anyway I&#039;ll add the &#039;log2ipf.pl&#039; perl script in the extended part of this article.  It&#039;s a perl script that&#039;s little more than an extended &#039;grep | sed&#039; which searches for text in a file and then reports how many results it found for each item.  In the default case using just &#039;log2ipf.pl somefile.log&#039; it searches for:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&quot;s9y&quot;=&amp;#62;qr/.&amp;#42;\&amp;#91;REJECTED&amp;#58;&amp;#160;&amp;#91;No&amp;#160;API-created&amp;#160;comments|Trackback&amp;#160;URL&amp;#160;invalid|Filtered&amp;#160;by&amp;#160;Akismet\.com&amp;#93;.&amp;#42;,&amp;#160;IP&amp;#160;&amp;#40;.&amp;#42;?&amp;#41;&amp;#93;.&amp;#42;/,&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
in this case it reports a list of IP addresses and how many times each IP address was &#039;caught&#039; trying to spam - but it could be modified to do anything.  For example I have another &#039;filter&#039; setup to see how many people use a google search to find pics on my server by searching for the term &#039;picasa.ini&#039;:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&quot;picasa&quot;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#62;qr/^.&amp;#42;?\s+&amp;#40;.&amp;#42;?&amp;#41;\s+.&amp;#42;%22index\+of%22\+%2F\+picasa\.ini.&amp;#42;/&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
so I can feed apache logfiles to log2ipf.pl using this commandline:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;;&amp;#160;log2ipf.pl&amp;#160;-l&amp;#160;picasa&amp;#160;/var/log/httpd/all/2006/07/&amp;#42;/&amp;#42;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;24.242.97.20&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&lt;br /&gt;
&amp;#160;&amp;#160;67.141.28.129&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
telling me there was just 2 such searches during July 2006 (woo).  I seem to remember that search returning more than that at the time I wrote the filter though lol.  You get the idea anyway.&lt;br /&gt;
&lt;br /&gt;
To add a new &#039;filter&#039;, best thing to do is import a sample logfile line you want to produce a result, then customize the script %re variable to include your custom filter.  &lt;br /&gt;
&lt;br /&gt;
For example, say you wanted to search for auth log failures for SSH (this is actually done for you by the periodic utility on FreeBSD if you set it up in /etc/periodic.conf, but that&#039;s another article! - you could write something like this for the %re filter:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;my&amp;#160;%re=&amp;#40;&lt;br /&gt;
&quot;s9y&quot;=&amp;#62;qr/.&amp;#42;\&amp;#91;REJECTED&amp;#58;&amp;#160;&amp;#91;No&amp;#160;API-created&amp;#160;comments|Trackback&amp;#160;URL&amp;#160;invalid|Filtered&amp;#160;by&amp;#160;Akismet\.com&amp;#93;.&amp;#42;,&amp;#160;IP&amp;#160;&amp;#40;.&amp;#42;?&amp;#41;&amp;#93;.&amp;#42;/,&lt;br /&gt;
#Example&amp;#160;of&amp;#160;logfile&amp;#160;line&amp;#160;we&amp;#160;want&amp;#160;to&amp;#160;catch&amp;#58;&lt;br /&gt;
#&amp;#160;Aug&amp;#160;26&amp;#160;14&amp;#58;57&amp;#58;35&amp;#160;users&amp;#160;sshd&amp;#91;30136&amp;#93;&amp;#58;&amp;#160;Failed&amp;#160;password&amp;#160;for&amp;#160;root&amp;#160;from&amp;#160;211.48.62.102&amp;#160;port&amp;#160;50706&amp;#160;ssh2&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;ssh&quot;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#62;qr/.&amp;#42;Failed&amp;#160;password&amp;#160;for&amp;#160;.&amp;#42;&amp;#160;from&amp;#160;&amp;#40;.&amp;#42;?&amp;#41;&amp;#160;.&amp;#42;/,&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&quot;picasa&quot;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;#62;qr/^.&amp;#42;?\s+&amp;#40;.&amp;#42;?&amp;#41;\s+.&amp;#42;%22index\+of%22\+%2F\+picasa\.ini.&amp;#42;/&lt;br /&gt;
&amp;#41;;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
which would result in:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;;&amp;#160;log2ipf.pl&amp;#160;-l&amp;#160;ssh&amp;#160;/var/log/auth.log&lt;br /&gt;
&amp;#160;168.126.71.148&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;210.34.14.53&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;3&lt;br /&gt;
&amp;#160;&amp;#160;84.10.149.105&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;3&lt;br /&gt;
&amp;#160;&amp;#160;211.48.62.102&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;3&lt;br /&gt;
&amp;#160;220.231.54.232&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;3&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;195.10.193.4&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;5&lt;br /&gt;
&amp;#160;213.179.181.26&amp;#58;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
As I say you can do the equivalent with grep, sed, sort and uniq on the commandline:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;;&amp;#160;grep&amp;#160;&quot;Failed&amp;#160;password&amp;#160;for&quot;&amp;#160;/var/log/auth.log&amp;#160;|&amp;#160;sed&amp;#160;-e&amp;#160;&#039;s/.&amp;#42;Failed&amp;#160;password&amp;#160;for&amp;#160;.&amp;#42;&amp;#160;from&amp;#160;\&amp;#40;&amp;#91;^&amp;#160;&amp;#93;&amp;#42;\&amp;#41;.&amp;#42;/\1/&#039;&amp;#160;\&lt;br /&gt;
&amp;#160;&amp;#160;|&amp;#160;sort&amp;#160;|&amp;#160;uniq&amp;#160;-c&amp;#160;|&amp;#160;sort&amp;#160;-n&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;1&amp;#160;168.126.71.148&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;3&amp;#160;210.34.14.53&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;3&amp;#160;211.48.62.102&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;3&amp;#160;220.231.54.232&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;3&amp;#160;84.10.149.105&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;5&amp;#160;195.10.193.4&lt;br /&gt;
&amp;#160;&amp;#160;11&amp;#160;213.179.181.26&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
But for a very large file the timing differences between this method and the perl script are massive.&lt;br /&gt;
&lt;br /&gt;
Anyhoo this is turning into a crazy long entry so I&#039;ll turn it in.  The script log2ipf.pl - should rename that really since it&#039;s got little to do with ipf really! - is in the extended article below if anyone&#039;s interested.&lt;br /&gt;
 &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/170-Serendipity-Spam-Statistics.html#extended&quot;&gt;Continue reading &quot;Serendipity Spam Statistics&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 31 Aug 2006 13:16:31 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/170-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Awstats Updates and Broken Icons</title>
    <link>http://freebsd.munk.me.uk/archives/164-Awstats-Updates-and-Broken-Icons.html</link>
            <category>Apache</category>
            <category>Perl</category>
    
    <comments>http://freebsd.munk.me.uk/archives/164-Awstats-Updates-and-Broken-Icons.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=164</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=164</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    &lt;a href=&quot;http://awstats.sourceforge.net/&quot;&gt;AWStats&lt;/a&gt; was recently updated from version 6.1 to 6.2.  Of itself this was no problem, checking the &lt;a href=&quot;http://cvs.sourceforge.net/viewcvs.py/*checkout*/awstats/awstats/docs/awstats_changelog.txt?rev=1.225&quot;&gt;changelog&lt;/a&gt; there is nothing significant that breaks anything.  However unfortunately the &lt;a href=&quot;http://www.freshports.org/www/awstats/&quot;&gt;AWStats FreeBSD port&lt;/a&gt; was modified by the port maintainer to correct &lt;a href=&quot;http://freebsd.munk.me.uk/exit.php?url=aHR0cDovL3d3dy5mcmVlYnNkLm9yZy9jZ2kvcXVlcnktcHIuY2dpP3ByPXBvcnRzLzc0Nzg4&quot;&gt;a problem that already existed - namely that some of the tools that ship with AWStats don&#039;t work because they can&#039;t find the files that they need - icon files for example&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The port maintainer modified the port so that the icon files for AWStats are now placed in /usr/local/www/awstats/icons/ - the original default location was /usr/local/www/icons/.  This took me a little while to figure out, perhaps it&#039;s the New Years hangover but a more detailed note in the /usr/ports/UPDATING file for current users of awstats would have been good.  Ho hum I suppose it&#039;s at least something that anything was added at all to UPDATING.  I&#039;m all for tidying up directory structures but in this case it seems that a &#039;fix&#039; for something that was trivially broken has actually resulted in breaking something that was working fine - as the saying goes if it ain&#039;t borked don&#039;t fix it.&lt;br /&gt;
&lt;br /&gt;
The short and tall of it is that to fix the problem that this &#039;fix&#039; created, a &#039;DirIcons&#039; directive needs to be added to each awstats config file:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;DirIcons=&quot;/awstatsicons&quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
and then an alias line needs to be added to the httpd.conf file:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;Alias&amp;#160;/awstatsicons&amp;#160;&quot;/usr/local/www/awstats/icons/&quot;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
otherwise the awstats pages look odd because the icon files can&#039;t be found.&lt;br /&gt;
&lt;br /&gt;
For posterity there&#039;s a GNATS message I drafted to be sent in reply to this &lt;a href=&quot;http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/74788&quot;&gt;FreeBSD Problem Report regarding the recent awstats update&lt;/a&gt; in the extended article below.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/164-Awstats-Updates-and-Broken-Icons.html#extended&quot;&gt;Continue reading &quot;Awstats Updates and Broken Icons&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sat, 01 Jan 2005 17:13:40 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/164-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Network Abuse Report Perl Script</title>
    <link>http://freebsd.munk.me.uk/archives/163-Network-Abuse-Report-Perl-Script.html</link>
            <category>Perl</category>
    
    <comments>http://freebsd.munk.me.uk/archives/163-Network-Abuse-Report-Perl-Script.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=163</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=163</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    I recently entered into a discussion on the &lt;a href=&quot;http://www.securityfocus.com/archive/75&quot;&gt;SecurityFocus Incidents Mailing List&lt;/a&gt; regarding the reporting of network attacks/incidents to the relevant authorities.  &lt;a href=&quot;http://www.securityfocus.com/archive/75/383685/2004-12-07/2004-12-13/0&quot;&gt;In the process of the conversation I happened to mention that I&#039;d written a small script to help automate the abuse reporting process&lt;/a&gt; and eventually ended up making &lt;a href=&quot;http://munk.me.uk/programming/perl/abuse_report.pl&quot;&gt;the perl abuse reporting script&lt;/a&gt; available online.&lt;br /&gt;
&lt;br /&gt;
To see the complete perl network abuse reporting script here, check out the extended article.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/163-Network-Abuse-Report-Perl-Script.html#extended&quot;&gt;Continue reading &quot;Network Abuse Report Perl Script&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 10 Dec 2004 14:46:33 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/163-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Upgrading Perl On FreeBSD</title>
    <link>http://freebsd.munk.me.uk/archives/160-Upgrading-Perl-On-FreeBSD.html</link>
            <category>Perl</category>
    
    <comments>http://freebsd.munk.me.uk/archives/160-Upgrading-Perl-On-FreeBSD.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=160</wfw:comment>

    <slash:comments>6</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=160</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    &lt;span style=&quot;font-weight:bold&quot;&gt;Please note after upgrading perl/changing to using perl in the ports you should now use the tool &#039;&lt;a href=http://people.freebsd.org/~tobez/pau.html&gt;perl-after-upgrade&lt;/a&gt;&#039; to upgrade any ports that rely on perl&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
After using the default base system installation of Perl 5.005_03 on my FreeBSD 4.x system forever, the time has finally come to upgrade to a more recent version of Perl.  The main reason for this is that a number of ports are now failing to upgrade because they require a later version of perl - 5.6.1 or 5.8.  For a while this was acceptable since the reasons for upgrading weren&#039;t critical; however recently we&#039;re getting more and more spam and it&#039;s likely this is because I&#039;ve not upgrade SpamAssassin in a while.&lt;br /&gt;
&lt;br /&gt;
This article details the steps involved in upgrading a FreeBSD system to use a newer version of Perl including upgrading all ports that depend on Perl to run successfully.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/160-Upgrading-Perl-On-FreeBSD.html#extended&quot;&gt;Continue reading &quot;Upgrading Perl On FreeBSD&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sat, 13 Nov 2004 22:50:11 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/160-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>MRTG Totals Perl Script</title>
    <link>http://freebsd.munk.me.uk/archives/157-MRTG-Totals-Perl-Script.html</link>
            <category>MRTG</category>
            <category>Perl</category>
    
    <comments>http://freebsd.munk.me.uk/archives/157-MRTG-Totals-Perl-Script.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=157</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=157</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    I recently got a mail from someone (hi &lt;a href=&quot;http://www.aroundmyroom.com/blog&quot;&gt;Dennis&lt;/a&gt;!) about how &lt;a href=&quot;http://mrtg.munk.me.uk/st510_tx_total.php&quot;&gt;the MRTG totals&lt;/a&gt; script works on &lt;a href=&quot;http://mrtg.munk.me.uk/&quot;&gt;the MRTG site&lt;/a&gt;.  For those too lazy to look at the totals page, the general idea is that the total transfer statistics for a device - in this case my ADSL router - are displayed all on one page.  In this way you can see easily how much data was transferred either by month or by day for any period during which the mrtg_total script has been collating data.&lt;br /&gt;
&lt;br /&gt;
I use a perl script written by a chap called Josef Wendel to collate the stats pages from a daily cron job.  The stats can then be displayed using a PHP script, again written by the same bloke.&lt;br /&gt;
&lt;br /&gt;
I can&#039;t find a specific reference to Josef&#039;s home site, but I&#039;m sure googling for &#039;josef wendel perl mrtg&#039; should turn something up (or even just google for &#039;mrtg_total.pl&#039;, the name of the script.  Just in case I&#039;ll add the scripts in the extended entry here anyway, I&#039;m sure Josef won&#039;t mind given I just mentioned his name about half a dozen times here in credit!!!&lt;br /&gt;
&lt;br /&gt;
Excellent script thanks for that Josef.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;EDIT:&lt;/b&gt;&lt;br /&gt;
Yes &lt;a href=&quot;http://www.google.com/search?&amp;q=mrtg_total.pl&quot;&gt;a quick google for mrtg_total.pl&lt;/a&gt; came up with &lt;a href=&quot;http://www.geocities.com/josef_wendel/mrtg_total.html&quot;&gt;Josef&#039;s home page for the mrtg total script&lt;/a&gt;.  Go google!  See over there for more &#039;authoratative&#039; info.&lt;br /&gt;
&lt;br /&gt;
See the extended article for the complete mrtg_total.pl script and associated PHP frontend script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/157-MRTG-Totals-Perl-Script.html#extended&quot;&gt;Continue reading &quot;MRTG Totals Perl Script&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sun, 19 Sep 2004 21:31:37 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/157-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Perl User Agent Grep Script</title>
    <link>http://freebsd.munk.me.uk/archives/155-Perl-User-Agent-Grep-Script.html</link>
            <category>Apache</category>
            <category>Perl</category>
    
    <comments>http://freebsd.munk.me.uk/archives/155-Perl-User-Agent-Grep-Script.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=155</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=155</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    This is here for reminders sake really.  Second time in a week I&#039;ve needed to use a perl sort construct and forgotten how it &#039;works&#039;.  Gist is to search for a certain field (user agent/robot) on each line from STDIN (a httpd access logfile), keep track of how many of each entry (robot) we find and finally print out the count (hits) for each entry (robot).&lt;br /&gt;
&lt;br /&gt;
Makes more sense when you execute the script perhaps.  Or not.  Whatever, it&#039;s just a reminder for the next time I need to use the sort &lt;a href=&quot;http://www.munk.me.uk/index.php?action=man&amp;manpage=perlfunc&amp;section=0&amp;submit=submit&quot;&gt;perlfunc&lt;/a&gt; on a hash. :P&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/bin/perl&lt;br /&gt;
=comment&lt;br /&gt;
Displays&amp;#160;number&amp;#160;of&amp;#160;hits&amp;#160;per&amp;#160;user&amp;#160;agent&amp;#160;to&amp;#160;a&amp;#160;httpd&amp;#160;access&amp;#160;logfile.&lt;br /&gt;
&lt;br /&gt;
Use&amp;#160;it&amp;#160;by&amp;#160;piping&amp;#160;logfile&amp;#160;lines&amp;#160;to&amp;#160;it&amp;#58;&lt;br /&gt;
&lt;br /&gt;
./ua_grep&amp;#160;somelogfile.log&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
grep&amp;#160;text_to_search_for_in_log&amp;#160;somelogfile.log&amp;#160;|&amp;#160;./ua_grep&lt;br /&gt;
=cut&lt;br /&gt;
&lt;br /&gt;
foreach&amp;#40;&amp;#60;&amp;#62;&amp;#41;{&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;split&amp;#160;/&quot;/;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;$UAs{&amp;#160;@_&amp;#91;5&amp;#93;&amp;#160;}++;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
foreach&amp;#160;$ua&amp;#160;&amp;#40;&amp;#160;sort&amp;#160;{&amp;#160;$UAs{$a}&amp;#160;&amp;#60;=&amp;#62;&amp;#160;$UAs{$b}&amp;#160;}&amp;#160;keys&amp;#160;%UAs&amp;#160;&amp;#41;&amp;#160;{&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;printf&amp;#160;&quot;%16s&amp;#160;-&amp;#62;&amp;#160;%d\n&quot;,&amp;#160;$ua,&amp;#160;$UAs{$ua};&lt;br /&gt;
}&lt;/div&gt; 
    </content:encoded>

    <pubDate>Tue, 07 Sep 2004 12:13:37 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/155-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Removing Users From The System</title>
    <link>http://freebsd.munk.me.uk/archives/149-Removing-Users-From-The-System.html</link>
            <category>Perl</category>
    
    <comments>http://freebsd.munk.me.uk/archives/149-Removing-Users-From-The-System.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=149</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=149</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    I wrote a few perl scripts a while ago to help add remove users from the system under an old old old eggshell.munk.me.uk user system.  I just stumbled across the scripts today after deciding I needed to purge the system of some users (ahhh, always feels good!!!).  Read the extended article for more info.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/149-Removing-Users-From-The-System.html#extended&quot;&gt;Continue reading &quot;Removing Users From The System&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Tue, 24 Aug 2004 01:34:18 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/149-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Perl Script for Displaying User's Shell Command History</title>
    <link>http://freebsd.munk.me.uk/archives/38-Perl-Script-for-Displaying-Users-Shell-Command-History.html</link>
            <category>Perl</category>
    
    <comments>http://freebsd.munk.me.uk/archives/38-Perl-Script-for-Displaying-Users-Shell-Command-History.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=38</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=38</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    This is a perl script I wrote to display user&#039;s shell command history.  The output can be limited to either all commands executed by any user that logged in on a given day or just to the commands executed by a single user during the period that their history file contains data for.&lt;br /&gt;
&lt;br /&gt;
The script was recently modified to distinguish between different years - when I originally wrote it I didn&#039;t think about what would happen when the script became over a year old (originally the script just output data for the current year only).  &lt;br /&gt;
&lt;br /&gt;
The script is also slightly limited in that if the user&#039;s shell is anything other than the C shell (CSH), then the output is just restricted to a note informing the admin that the user logged in on that day in the case the shell is Bourne, or an output of all commands in the history file in the case the shell is some other shell.&lt;br /&gt;
&lt;br /&gt;
The script follows in the extended article together with some hints on usage via cron.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;&lt;a href=&quot;http://freebsd.munk.me.uk/archives/38-Perl-Script-for-Displaying-Users-Shell-Command-History.html#extended&quot;&gt;Continue reading &quot;Perl Script for Displaying User&#039;s Shell Command History&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Wed, 07 Jan 2004 06:37:40 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/38-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Email signatures using FIFO</title>
    <link>http://freebsd.munk.me.uk/archives/27-Email-signatures-using-FIFO.html</link>
            <category>Perl</category>
    
    <comments>http://freebsd.munk.me.uk/archives/27-Email-signatures-using-FIFO.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=27</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=27</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    Mmm... working on a system adduser script at the moment and happened across an interesting snippet on using FIFOs in the &lt;a href=&quot;http://www.munk.me.uk/index.php?action=man&amp;manpage=perlipc&amp;section=0&quot;&gt;perlipc manpage&lt;/a&gt;.  The example they give includes a short script for creating a randomly generated email signature for use with an MUA - something I was looking for a while ago but never got around to investigating (always the way:P).&lt;br /&gt;
&lt;br /&gt;
Lesson learnt:  always &lt;a href=&quot;http://www.google.com/search?num=100&amp;hl=en&amp;lr=&amp;ie=UTF-8&amp;oe=UTF-8&amp;newwindow=1&amp;safe=off&amp;q=rtfm&quot;&gt;RTFM&lt;/a&gt; - all of them!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;Named&amp;#160;Pipes&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;A&amp;#160;named&amp;#160;pipe&amp;#160;&amp;#40;often&amp;#160;referred&amp;#160;to&amp;#160;as&amp;#160;a&amp;#160;FIFO&amp;#41;&amp;#160;is&amp;#160;an&amp;#160;old&amp;#160;Unix&amp;#160;IPC&amp;#160;mechanism&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;for&amp;#160;processes&amp;#160;communicating&amp;#160;on&amp;#160;the&amp;#160;same&amp;#160;machine.&amp;#160;&amp;#160;It&amp;#160;works&amp;#160;just&amp;#160;like&amp;#160;a&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;regular,&amp;#160;connected&amp;#160;anonymous&amp;#160;pipes,&amp;#160;except&amp;#160;that&amp;#160;the&amp;#160;processes&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;rendezvous&amp;#160;using&amp;#160;a&amp;#160;filename&amp;#160;and&amp;#160;don&#039;t&amp;#160;have&amp;#160;to&amp;#160;be&amp;#160;related.&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;To&amp;#160;create&amp;#160;a&amp;#160;named&amp;#160;pipe,&amp;#160;use&amp;#160;the&amp;#160;Unix&amp;#160;command&amp;#160;mknod&amp;#40;1&amp;#41;&amp;#160;or&amp;#160;on&amp;#160;some&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;systems,&amp;#160;mkfifo&amp;#40;1&amp;#41;.&amp;#160;&amp;#160;These&amp;#160;may&amp;#160;not&amp;#160;be&amp;#160;in&amp;#160;your&amp;#160;normal&amp;#160;path.&lt;br /&gt;
&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;#&amp;#160;system&amp;#160;return&amp;#160;val&amp;#160;is&amp;#160;backwards,&amp;#160;so&amp;#160;&amp;amp;&amp;amp;&amp;#160;not&amp;#160;||&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;#&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;$ENV{PATH}&amp;#160;.=&amp;#160;&quot;&amp;#58;/etc&amp;#58;/usr/etc&quot;;&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;if&amp;#160;&amp;#160;&amp;#40;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;system&amp;#40;&#039;mknod&#039;,&amp;#160;&amp;#160;$path,&amp;#160;&#039;p&#039;&amp;#41;&lt;br /&gt;
		&amp;#160;&amp;#160;&amp;#160;&amp;amp;&amp;amp;&amp;#160;system&amp;#40;&#039;mkfifo&#039;,&amp;#160;$path&amp;#41;&amp;#160;&amp;#41;&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;{&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;die&amp;#160;&quot;mk{nod,fifo}&amp;#160;$path&amp;#160;failed&quot;;&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;}&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;A&amp;#160;fifo&amp;#160;is&amp;#160;convenient&amp;#160;when&amp;#160;you&amp;#160;want&amp;#160;to&amp;#160;connect&amp;#160;a&amp;#160;process&amp;#160;to&amp;#160;an&amp;#160;unrelated&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;one.&amp;#160;&amp;#160;When&amp;#160;you&amp;#160;open&amp;#160;a&amp;#160;fifo,&amp;#160;the&amp;#160;program&amp;#160;will&amp;#160;block&amp;#160;until&amp;#160;there&#039;s&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;something&amp;#160;on&amp;#160;the&amp;#160;other&amp;#160;end.&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;For&amp;#160;example,&amp;#160;let&#039;s&amp;#160;say&amp;#160;you&#039;d&amp;#160;like&amp;#160;to&amp;#160;have&amp;#160;your&amp;#160;.signature&amp;#160;file&amp;#160;be&amp;#160;a&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;named&amp;#160;pipe&amp;#160;that&amp;#160;has&amp;#160;a&amp;#160;Perl&amp;#160;program&amp;#160;on&amp;#160;the&amp;#160;other&amp;#160;end.&amp;#160;&amp;#160;Now&amp;#160;every&amp;#160;time&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;any&amp;#160;program&amp;#160;&amp;#40;like&amp;#160;a&amp;#160;mailer,&amp;#160;news&amp;#160;reader,&amp;#160;finger&amp;#160;program,&amp;#160;etc.&amp;#41;&amp;#160;tries&amp;#160;to&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;read&amp;#160;from&amp;#160;that&amp;#160;file,&amp;#160;the&amp;#160;reading&amp;#160;program&amp;#160;will&amp;#160;block&amp;#160;and&amp;#160;your&amp;#160;program&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;will&amp;#160;supply&amp;#160;the&amp;#160;new&amp;#160;signature.&amp;#160;&amp;#160;We&#039;ll&amp;#160;use&amp;#160;the&amp;#160;pipe-checking&amp;#160;file&amp;#160;test&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;-p&amp;#160;to&amp;#160;find&amp;#160;out&amp;#160;whether&amp;#160;anyone&amp;#160;&amp;#40;or&amp;#160;anything&amp;#41;&amp;#160;has&amp;#160;accidentally&amp;#160;removed&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;our&amp;#160;fifo.&lt;br /&gt;
&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;chdir;&amp;#160;#&amp;#160;go&amp;#160;home&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;$FIFO&amp;#160;=&amp;#160;&#039;.signature&#039;;&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;$ENV{PATH}&amp;#160;.=&amp;#160;&quot;&amp;#58;/etc&amp;#58;/usr/games&quot;;&lt;br /&gt;
&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;while&amp;#160;&amp;#40;1&amp;#41;&amp;#160;{&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;unless&amp;#160;&amp;#40;-p&amp;#160;$FIFO&amp;#41;&amp;#160;{&lt;br /&gt;
		&amp;#160;&amp;#160;&amp;#160;unlink&amp;#160;$FIFO;&lt;br /&gt;
		&amp;#160;&amp;#160;&amp;#160;system&amp;#40;&#039;mknod&#039;,&amp;#160;$FIFO,&amp;#160;&#039;p&#039;&amp;#41;&lt;br /&gt;
		&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;amp;&amp;amp;&amp;#160;die&amp;#160;&quot;can&#039;t&amp;#160;mknod&amp;#160;$FIFO&amp;#58;&amp;#160;$!&quot;;&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;br /&gt;
&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;#&amp;#160;next&amp;#160;line&amp;#160;blocks&amp;#160;until&amp;#160;there&#039;s&amp;#160;a&amp;#160;reader&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;open&amp;#160;&amp;#40;FIFO,&amp;#160;&quot;&amp;#62;&amp;#160;$FIFO&quot;&amp;#41;&amp;#160;||&amp;#160;die&amp;#160;&quot;can&#039;t&amp;#160;write&amp;#160;$FIFO&amp;#58;&amp;#160;$!&quot;;&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;print&amp;#160;FIFO&amp;#160;&quot;John&amp;#160;Smith&amp;#160;&amp;#40;smith\@host.org&amp;#41;\n&quot;,&amp;#160;`fortune&amp;#160;-s`;&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;close&amp;#160;FIFO;&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;sleep&amp;#160;2;&amp;#160;&amp;#160;&amp;#160;&amp;#160;#&amp;#160;to&amp;#160;avoid&amp;#160;dup&amp;#160;signals&lt;br /&gt;
	&amp;#160;&amp;#160;&amp;#160;}&lt;/div&gt; 
    </content:encoded>

    <pubDate>Fri, 19 Dec 2003 02:19:22 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/27-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>
<item>
    <title>Random password generation using Crypt::GeneratePassword</title>
    <link>http://freebsd.munk.me.uk/archives/25-Random-password-generation-using-CryptGeneratePassword.html</link>
            <category>Perl</category>
    
    <comments>http://freebsd.munk.me.uk/archives/25-Random-password-generation-using-CryptGeneratePassword.html#comments</comments>
    <wfw:comment>http://freebsd.munk.me.uk/wfwcomment.php?cid=25</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://freebsd.munk.me.uk/rss.php?version=2.0&amp;type=comments&amp;cid=25</wfw:commentRss>
    

    <author>nospam@example.com (munk)</author>
    <content:encoded>
    Just started on an extended &#039;adduser&#039; script and needed a quick and easy random password generation tool - Crypt::GeneratePassword does the job rather nicely.&lt;br /&gt;
&lt;br /&gt;
I&#039;ll paste links to the finished script when I&#039;ve ... finished it!&lt;br /&gt;
&lt;br /&gt;
For now the link to Crypt::GeneratePassword is here:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://search.cpan.org/author/JWALT/Crypt-GeneratePassword-0.03/lib/Crypt/GeneratePassword.pm&quot;&gt;http://search.cpan.org/author/JWALT/Crypt-GeneratePassword-0.03/lib/Crypt/GeneratePassword.pm&lt;/a&gt; 
    </content:encoded>

    <pubDate>Fri, 19 Dec 2003 00:53:52 +0000</pubDate>
    <guid isPermaLink="false">http://freebsd.munk.me.uk/archives/25-guid.html</guid>
    <creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license>
</item>

</channel>
</rss>