<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kastang &#187; ubuntu</title>
	<atom:link href="http://kastang.com/blog/tag/ubuntu/feed/" rel="self" type="application/rss+xml" />
	<link>http://kastang.com</link>
	<description>Ramblings of a Geek</description>
	<lastBuildDate>Sat, 11 Jun 2011 00:30:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Push Twitter Replies to your iPhone using Prowl</title>
		<link>http://kastang.com/blog/2010/08/push-twitter-replies-to-iphone-using-prowl/</link>
		<comments>http://kastang.com/blog/2010/08/push-twitter-replies-to-iphone-using-prowl/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 23:19:24 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Prowl]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://kastang.com/?p=537</guid>
		<description><![CDATA[Yesterday I bought Prowl for the iPhone. Prowl is similar to Growl on OSX systems. Prowl pushes notifications to your iPhone or iTouch. One of the first uses I thought to use Prowl for was pushing my @replies and mentions from Twitter to my iPhone. I wanted to run the script from my Ubuntu server [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I bought Prowl for the iPhone. Prowl is similar to Growl on OSX systems. Prowl pushes notifications to your iPhone or iTouch. One of the first uses I thought to use Prowl for was pushing my @replies and mentions from Twitter to my iPhone. I wanted to run the script from my Ubuntu server rather then keeping my desktop on 24/7. I did a quick search online and didn't find any command line options for achieving such a task.  I decided to code a quick and dirty PHP script to accomplish what I wanted to do.</p>
<p>This is a quick hack. There are probably more efficient ways of accomplishing this task. I used <a href="http://github.com/Fenric/ProwlPHP">ProwlPHP</a> to link to the Prowl API.</p>
<p>I assume you know PHP and know how to navigate in Terminal. This is a command line app, it will run on any computer/server running PHP. I have extensively commented the script. Hopefully it is easy to follow along.</p>
<p>Quick Instructions:</p>
<ol>
<li>Download the newest version of ProwlPHP and copy it a directory.</li>
<li>Create a file lastreply.txt and stick in in the same directory as the below code will be copied into. This file needs to have read and write permissions.</li>
<li>Copy the below code into another file. Alter the ProwlPHP includes directory on line 2, and add your Prowl API key, Twitter Username, and Twitter Password in the constructor.</li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//CHANGE THIS PATH TO WHERE ProwlPHP IS LOCATED ON</span>
<span style="color: #666666; font-style: italic;">//YOUR SERVER</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'../API/ProwlPHP.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$t</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Twitter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * @class Twitter
 * This class integrates Twitter and Prowl notifications with the
 * iPhone. When this script runs it checks to see if any new
 * Twitter mentions have occured on your account since last check.
 * If any exist, the Tweet is sent to Prowl and will be notified
 * via push on your iPhone.
 *
 * This class uses ProwlPHP located at:
 * 			http://github.com/Fenric/ProwlPHP
 *
 * @author Kastang (josh dot kastang at gmail dot com)
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Twitter <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$lastID</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$tUser</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$tPass</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$prowl</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Constructor for Twitter Class. Three lines need to be edited
     * below before running the file: prowl, tUser, and tPass.
     */</span>
    <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//EDIT THE 3 LINES BELOW</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prowl</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Prowl<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'YOUR PROWL API KEY'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tUser</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;TWITTER USERNAME&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tPass</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;TWITTER PASSWORD&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//XML info loaded from Twitter API.</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getReplies</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//Opens the lastreply file which contants the</span>
        <span style="color: #666666; font-style: italic;">//id of the last mentioned tweet.</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lastID</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lastreply.txt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//If the file is empty (probably the first time</span>
        <span style="color: #666666; font-style: italic;">//you are using the script). It will pull the</span>
        <span style="color: #666666; font-style: italic;">//newest mention id from your twitter feed and</span>
        <span style="color: #666666; font-style: italic;">//store it in the file.</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lastID</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lastID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">status</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$full</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;@&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">status</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">screen_name</span> <span style="color: #339933;">.</span>
                    <span style="color: #0000ff;">&quot;: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">status</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">text</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prowl</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$full</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateNewest</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">status</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//Checks for new Twitter Mentions.</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">checkForUpdates</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Checks for updates.
     */</span>
    <span style="color: #000000; font-weight: bold;">function</span> checkForUpdates<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//first run boolean.</span>
        <span style="color: #000088;">$first</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//For each mention in the XML array, check to see if</span>
        <span style="color: #666666; font-style: italic;">//the current ID is greater then the last recorded ID.</span>
        <span style="color: #666666; font-style: italic;">//If it is, push the current Tweet to Prowl, if it isn't,</span>
        <span style="color: #666666; font-style: italic;">//check to see if it is the first run, if it is, break out</span>
        <span style="color: #666666; font-style: italic;">//of the for loop, if it isn't the first run, update the</span>
        <span style="color: #666666; font-style: italic;">//lastreply.txt file and break from the forloop.</span>
        <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>             <span style="color: #000088;">$curr</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">status</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$curr</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lastID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$first</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$full</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;@&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">status</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">screen_name</span> <span style="color: #339933;">.</span>
                        <span style="color: #0000ff;">&quot;: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">status</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">text</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prowl</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$full</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$first</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateNewest</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">status</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Writes the newest @reply id to a file.
     */</span>
    <span style="color: #000000; font-weight: bold;">function</span> updateNewest<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;lastreply.txt&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;w&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Push the Tweet to Prowl. This code is modified from
     * example.php in the ProwlPHP API Wrapper.
     */</span>
    <span style="color: #000000; font-weight: bold;">function</span> prowl<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tweet</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prowl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">push</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'application'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Twitter'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'event'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Reply'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$tweet</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'priority'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Gets replies from Twitter. In order to grab replies, you
     * must be authenticated.
     */</span>
    <span style="color: #000000; font-weight: bold;">function</span> getReplies<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$twitterHost</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://twitter.com/statuses/mentions.xml&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$curl</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_HEADER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_HTTPAUTH<span style="color: #339933;">,</span> CURLAUTH_BASIC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_USERPWD<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$this-&gt;tUser</span>:<span style="color: #006699; font-weight: bold;">$this-&gt;tPass</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_HTTP_VERSION<span style="color: #339933;">,</span> CURL_HTTP_VERSION_1_1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$twitterHost</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-Type: application/xml; charset=ISO-8859-1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I chose to add an entry in my crontab to run this script every 10 minutes. The time can be adjusted to suit your needs. Personally I do not see a need to ping Twitter more then once every ten minutes.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*/</span><span style="color: #000000;">10</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> curl <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>replies.php</pre></div></div>

<p>If all goes well, you should see something like this when someone mentions you in a tweet:</p>
<div id="attachment_547" class="wp-caption aligncenter" style="width: 394px"><a href="http://kastang.com/blog/wp-content/uploads/2010/08/photo-1.png"><img class="size-full wp-image-547 " title="Prowl iPhone Lockscreen" src="http://kastang.com/blog/wp-content/uploads/2010/08/photo-1.png" alt="Prowl pushing a notification to the iPhone. " width="384" height="576" /></a><p class="wp-caption-text">Prowl pushing a notification to the iPhone. </p></div>
<p>It is possible to setup a redirection within Prowl to automatically launch your Twitter client of choice when you get a Twitter based notification. You can also open Prowl and view all notifications:</p>
<div id="attachment_548" class="wp-caption aligncenter" style="width: 394px"><a href="http://kastang.com/blog/wp-content/uploads/2010/08/photo-2.png"><img class="size-full wp-image-548 " title="Prowl Main Screen" src="http://kastang.com/blog/wp-content/uploads/2010/08/photo-2.png" alt="Prowl Main Screen" width="384" height="576" /></a><p class="wp-caption-text">Prowl Main Screen</p></div>
<p>The script should be fairly easy to modify. I will probably add Direct Messaging next to my Prowl Push Notifications.</p>
]]></content:encoded>
			<wfw:commentRss>http://kastang.com/blog/2010/08/push-twitter-replies-to-iphone-using-prowl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AWStats on Ubuntu 10.04 Server</title>
		<link>http://kastang.com/blog/2010/07/awstats-on-ubuntu-10-04-server/</link>
		<comments>http://kastang.com/blog/2010/07/awstats-on-ubuntu-10-04-server/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 15:28:17 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[AWStats]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://kastang.com/?p=461</guid>
		<description><![CDATA[Yesterday I finalized moving my websites to my new Linode. With all the base configuration done, it is time to start installing some monitoring and stats tools. AWStats in particular is one of my favorite tools for analyzing web traffic. This guide assumes you are using Apache2, Ubuntu 10.04(though I would assume to process would [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I finalized moving my websites to my new Linode. With all the base configuration done, it is time to start installing some monitoring and stats tools. AWStats in particular is one of my favorite tools for analyzing web traffic. </p>
<p>This guide assumes you are using Apache2, Ubuntu 10.04(though I would assume to process would be similar for Ubuntu 9.xx), and have root access to your box. Also I assume you have Apache properly setup with a working access.log file.</p>
<h2>Installing AWStats</h2>
<p>Ubuntu 10.04 has AWStats available in their repositories:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> awstats</pre></div></div>

<p>The Ubuntu Repo. does not have the newest version of AWStats. The repo has 6.9 while the newest, stable, version is 6.95. The 6.9 install that Ubuntu provides should be enough for most people. If you wish, you can install the newest version manually and continue following afterwards. </p>
<h2>Configuring AWStats</h2>
<p><em>AWStats does offer some sort of automated configuration process. I have never used or tested this function. If you are not comfortable with manual configuration you may want to look up the automated configuration option. </em></p>
<p>I have multiple domains I wish to track. I needed to make a copy of the default <code>awstats.conf</code> file for each domain. I used the format <code>awstats.mydomain.ext.conf</code> for my configuration file name. In my case, <code>mydomain.ext</code> is <code>kastang.com</code>. You will have to create a copy of <code>awstats.conf</code> for each domain you want to monitor.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>awstats<span style="color: #000000; font-weight: bold;">/</span>awstats.conf <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>awstats<span style="color: #000000; font-weight: bold;">/</span>awstats.yourdomain.ext.conf</pre></div></div>

<p>Open <code>awstats.yourdomain.ext.conf</code>, find and modify the following fields:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#Path to access.log for your domain</span>
<span style="color: #007800;">LogFile</span>=<span style="color: #ff0000;">&quot;/var/log/apache2/access.log&quot;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">#I recommend '1' for more detailed information</span>
<span style="color: #007800;">LogFormat</span>=<span style="color: #000000;">1</span>  
&nbsp;
<span style="color: #007800;">SiteDomain</span>=<span style="color: #ff0000;">&quot;yourdomain.ext&quot;</span>
&nbsp;
<span style="color: #007800;">HostAliases</span>=<span style="color: #ff0000;">&quot;localhost 127.0.0.1 yourdomain.ext&quot;</span></pre></div></div>

<p>Now we can generate the initial stats for AWStats based off of your existing access.log file. You need to run this command for every domain you have configured.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cgi-bin<span style="color: #000000; font-weight: bold;">/</span>awstats.pl <span style="color: #660033;">-config</span>=yourdomain.ext <span style="color: #660033;">-update</span></pre></div></div>

<p>Check the output for any errors. If it successfully Finds/Parses your access.log file you should be good to continue. If you have any errors, double check your configuration file and make sure the path to the access.log is correct.</p>
<h2>Configuring Apache</h2>
<p>After configuring AWStats, we need to tell Apache where to point when the AWStats address is accessed.</p>
<p>Navigate to /etc/apache2/sites-available/. If you have no VirtualHosts setup, you will want to place the following code in 'default'. If you have VirtualHosts setup, add this code inside the <code>VirtualHost</code> tag for each domain you want to monitor.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Alias <span style="color: #000000; font-weight: bold;">/</span>awstatsclasses <span style="color: #ff0000;">&quot;/usr/share/awstats/lib/&quot;</span>
Alias <span style="color: #000000; font-weight: bold;">/</span>awstats-icon<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #ff0000;">&quot;/usr/share/awstats/icon/&quot;</span>
Alias <span style="color: #000000; font-weight: bold;">/</span>awstatscss <span style="color: #ff0000;">&quot;/usr/share/doc/awstats/examples/css&quot;</span>
ScriptAlias <span style="color: #000000; font-weight: bold;">/</span>cgi-bin<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cgi-bin<span style="color: #000000; font-weight: bold;">/</span>
ScriptAlias <span style="color: #000000; font-weight: bold;">/</span>awstats<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cgi-bin<span style="color: #000000; font-weight: bold;">/</span>
Options ExecCGI <span style="color: #660033;">-MultiViews</span> +SymLinksIfOwnerMatch</pre></div></div>

<p>Reload the Apache configuration:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 reload</pre></div></div>

<p>Check to make sure you do not have and errors or warnings. Depending how you originally setup your Apache config, the /cgi-bin/ ScriptAlias may already be implemented. In this case, just remove that line from the configuration file. (Don't forget to reload the configuration after all changes).</p>
<p>You should now be able to navigate to <code>http://yourdomain.ext/awstats/awstats.pl</code> and see the existing webstats from your access.log file.</p>
<h2>Automating AWStats updates</h2>
<p>AWStats will not automatically update by default. I cuggest using Cron to automate the process:</p>
<p>Add this to crontab and it will update stats once every three hours. You can adjust the timing to suit your needs. I have seen AWStats update on a weekly basis, daily basis, and even sometimes every couple minutes. You will need to add a separate crontab line for each domain AWStat is monitoring.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">*/</span><span style="color: #000000;">3</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> root <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cgi-bin<span style="color: #000000; font-weight: bold;">/</span>awstats.pl <span style="color: #660033;">-config</span>=yourdomain.ext <span style="color: #660033;">-update</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div>

<h2>Securing AWStats</h2>
<p>If you are at this step, you should have a working AWStats. One issue is AWStats does not come secured by default. They do offer to enable Authentication in the configuration, but I think it is just easier to generate a simple <code>.htaccess</code> file. This method is a quick and dirty method for securing AWStats. If you require a more sophisticated method of securing AWStats, please consult the official documentation.</p>
<p>Navigate to <code>/usr/lib/cgi-bin/</code> this is where awstats.pl is located. </p>
<p>Create a new .htpasswd file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">htpasswd <span style="color: #660033;">-cb</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>.htpasswd username password</pre></div></div>

<p>Create a new .htaccess file with the following inside:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">AuthName <span style="color: #ff0000;">&quot;AWStats Authentication&quot;</span>
AuthType Basic
AuthUserFile <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>.htpasswd
Require valid-user</pre></div></div>

<p>Now if all goes well, when you refresh your browser you will be prompted to enter a username and password to access AWStats. </p>
<p>This should get you to a point where AWStats is usable and (reasonably) secure. From here you can add Plugins or further configure AWStats to fit your individual needs. </p>
]]></content:encoded>
			<wfw:commentRss>http://kastang.com/blog/2010/07/awstats-on-ubuntu-10-04-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adjust ATI Fan Speed in Ubuntu</title>
		<link>http://kastang.com/blog/2009/08/manually-change-ati-fan-speed-in-ubunt/</link>
		<comments>http://kastang.com/blog/2009/08/manually-change-ati-fan-speed-in-ubunt/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 23:36:33 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ati fan speed]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://kastang.com/?p=195</guid>
		<description><![CDATA[I found this post hovering in my Drafts folder today, the blog post is old but the information still applies. Currently ATI drivers do not have the ability to modify fan speeds from their GUI. Here is a quick and easy way to manually adjust  fan speeds via Terminal. The commands below work with my ATI [...]]]></description>
			<content:encoded><![CDATA[<p><em>I found this post hovering in my Drafts folder today, the blog post is old but the information still applies. </em></p>
<p>Currently ATI drivers do not have the ability to modify fan speeds from their GUI. Here is a quick and easy way to manually adjust  fan speeds via Terminal. The commands below work with my ATI Radeon 4870 card, I would assume they will also work with any ATI card with a fan though. <strong>Note: ATI drivers from ATI website are required.</strong></p>
<p>To check the temperature of your card:<br />
<span style="font-family: Consolas; line-height: 18px; font-size: 12px; white-space: pre;">aticonfig --adapter=0 --od-gettemperature</span></p>
<p>To change the fan speed:<br />
<span style="font-family: Consolas; line-height: 18px; font-size: 12px; white-space: pre;">aticonfig --pplib-cmd "set fanspeed 0 XX"<br />
<span style="font-family: Georgia; line-height: 19px; white-space: normal; font-size: 13px;">(Where the XX is replace it with the fan speed percentage)</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://kastang.com/blog/2009/08/manually-change-ati-fan-speed-in-ubunt/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

