<?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>klkl &#187; Linux</title>
	<atom:link href="http://klkl.co.uk/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://klkl.co.uk</link>
	<description>it's easy to type</description>
	<lastBuildDate>Tue, 11 Oct 2011 14:53:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>One Line PERL Find / Replace</title>
		<link>http://klkl.co.uk/2011/02/24/one-line-perl-find-replace/</link>
		<comments>http://klkl.co.uk/2011/02/24/one-line-perl-find-replace/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 08:00:53 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[PERL]]></category>
		<category><![CDATA[replace]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=297</guid>
		<description><![CDATA[<h2 style="text-align: center;"><span style="color: #888888;">perl -pi -e &#8217;s/find/replace/g&#8217; file.name(s)</span></h2>
]]></description>
			<content:encoded><![CDATA[<h2 style="text-align: center;"><span style="color: #888888;">perl -pi -e &#8217;s/find/replace/g&#8217; file.name(s)</span></h2>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2011/02/24/one-line-perl-find-replace/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>HowTo: Mac OS X Flush DNS Cache</title>
		<link>http://klkl.co.uk/2010/04/11/howto-mac-os-x-flush-dns-cache/</link>
		<comments>http://klkl.co.uk/2010/04/11/howto-mac-os-x-flush-dns-cache/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 13:40:24 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[flush]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=257</guid>
		<description><![CDATA[<p>While playing with my /etc/hosts file for testing a new server setup I needed to flush my DNS cache. As ever, terminal came to my aid.</p>
<h4 style="padding-left: 30px;"><strong>dscacheutil -flushcache</strong></h4>
<p>Now all is well in the world of DNS.</p>
]]></description>
			<content:encoded><![CDATA[<p>While playing with my /etc/hosts file for testing a new server setup I needed to flush my DNS cache. As ever, terminal came to my aid.</p>
<h4 style="padding-left: 30px;"><strong>dscacheutil -flushcache</strong></h4>
<p>Now all is well in the world of DNS.</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2010/04/11/howto-mac-os-x-flush-dns-cache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connecting to MySQL Over SSH</title>
		<link>http://klkl.co.uk/2010/03/21/connecting-to-mysql-over-ssh/</link>
		<comments>http://klkl.co.uk/2010/03/21/connecting-to-mysql-over-ssh/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 14:06:56 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[tunnel]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=251</guid>
		<description><![CDATA[<p>The last couple of days I&#8217;ve been thinking about setting up a local copy of my websites on my laptop so that I can develop them before I make them live.</p>
<p>Last night I enabled PHP on the apache server built into Mac OSX on my new laptop and installed MySQL on it. I also set up some bash aliases to rsync commands so that I could synchronise the websites from the server to the laptop and back again.</p>
<p>Now that I had local copies of the sites that are synchronised it was time to turn my attention to synchronising the databases between the server and my local machine. I could of configured the server&#8217;s MySQL installation to allow remote connections, however, I did not want to do this for security reasons. I decided that I would connect to the MySQL server over SSH by forwarding a port on my local machine to a remote port on the server.</p>
<p>First I needed to create an SSH tunnel using the following command</p>
<p style="padding-left: 30px;">ssh -fNg -L 3307:127.0.0.1:3306 server.host.name<span id="more-251"></span></p>
<p>The options for SSH are</p>
<ul>
<li>f
<ul>
<li>Requests SSH to background so that you do not have to keep a terminal connected to the server open</li>
</ul>
</li>
<li>N
<ul>
<li>Does not execute a remote command (useful for just forwarding ports)</li>
</ul>
</li>
<li>g
<ul>
<li>Allows remote hosts to connect to local forwarded ports</li>
</ul>
</li>
<li>L
<ul>
<li>Specifies that a local port (3307) is forwarded to the given host (server.host.name) and port (3306)</li>
</ul>
</li>
</ul>
<p>I created an alias to that command for easy use in future but I&#8217;ll need to make sure the tunnel is active before trying to connect to the remote server.</p>
<p>Next its time to turn our attention to actually connecting to the remote MySQL server.</p>
<p style="padding-left: 30px;">mysql -h 127.0.0.1 -P 3307 -u username -p</p>
<p>The Options:</p>
<ul>
<li>h specifies the host to connect to (must be 127.0.0.1)</li>
<li>P specifies the port to connect to (your locally forwarded port)</li>
<li>u specifies the username to connect with</li>
<li>p will prompt you for your password (&#8211;password=passtext can be used to give the password)</li>
</ul>
<p>Thats if I wanted to connect to the remote MySQL server on the command line. The latest phpmyadmin has an option for syncronizing databases in which case you can put the above details and it will compare the databases and allow you to choose what to synchronise.</p>
]]></description>
			<content:encoded><![CDATA[<p>The last couple of days I&#8217;ve been thinking about setting up a local copy of my websites on my laptop so that I can develop them before I make them live.</p>
<p>Last night I enabled PHP on the apache server built into Mac OSX on my new laptop and installed MySQL on it. I also set up some bash aliases to rsync commands so that I could synchronise the websites from the server to the laptop and back again.</p>
<p>Now that I had local copies of the sites that are synchronised it was time to turn my attention to synchronising the databases between the server and my local machine. I could of configured the server&#8217;s MySQL installation to allow remote connections, however, I did not want to do this for security reasons. I decided that I would connect to the MySQL server over SSH by forwarding a port on my local machine to a remote port on the server.</p>
<p>First I needed to create an SSH tunnel using the following command</p>
<p style="padding-left: 30px;">ssh -fNg -L 3307:127.0.0.1:3306 server.host.name<span id="more-251"></span></p>
<p>The options for SSH are</p>
<ul>
<li>f
<ul>
<li>Requests SSH to background so that you do not have to keep a terminal connected to the server open</li>
</ul>
</li>
<li>N
<ul>
<li>Does not execute a remote command (useful for just forwarding ports)</li>
</ul>
</li>
<li>g
<ul>
<li>Allows remote hosts to connect to local forwarded ports</li>
</ul>
</li>
<li>L
<ul>
<li>Specifies that a local port (3307) is forwarded to the given host (server.host.name) and port (3306)</li>
</ul>
</li>
</ul>
<p>I created an alias to that command for easy use in future but I&#8217;ll need to make sure the tunnel is active before trying to connect to the remote server.</p>
<p>Next its time to turn our attention to actually connecting to the remote MySQL server.</p>
<p style="padding-left: 30px;">mysql -h 127.0.0.1 -P 3307 -u username -p</p>
<p>The Options:</p>
<ul>
<li>h specifies the host to connect to (must be 127.0.0.1)</li>
<li>P specifies the port to connect to (your locally forwarded port)</li>
<li>u specifies the username to connect with</li>
<li>p will prompt you for your password (&#8211;password=passtext can be used to give the password)</li>
</ul>
<p>Thats if I wanted to connect to the remote MySQL server on the command line. The latest phpmyadmin has an option for syncronizing databases in which case you can put the above details and it will compare the databases and allow you to choose what to synchronise.</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2010/03/21/connecting-to-mysql-over-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using mysqladmin to Change the root Password</title>
		<link>http://klkl.co.uk/2010/03/20/using-mysqladmin-to-change-the-root-password/</link>
		<comments>http://klkl.co.uk/2010/03/20/using-mysqladmin-to-change-the-root-password/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 22:08:46 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[root]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=245</guid>
		<description><![CDATA[<p>If you have never set a root password for MySQL, the server does not require a password at all for connecting as root.</p>
<p>To setup root password for first time, use mysqladmin command at shell prompt as follows:</p>
<p style="padding-left: 30px;">$ mysqladmin -u root password NEWPASSWORD</p>
<p>However, if you want to change (or update) a root password, then you need to use following command</p>
<p style="padding-left: 30px;">$ mysqladmin -u root -p&#8217;oldpassword&#8217; password newpass</p>
]]></description>
			<content:encoded><![CDATA[<p>If you have never set a root password for MySQL, the server does not require a password at all for connecting as root.</p>
<p>To setup root password for first time, use mysqladmin command at shell prompt as follows:</p>
<p style="padding-left: 30px;">$ mysqladmin -u root password NEWPASSWORD</p>
<p>However, if you want to change (or update) a root password, then you need to use following command</p>
<p style="padding-left: 30px;">$ mysqladmin -u root -p&#8217;oldpassword&#8217; password newpass</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2010/03/20/using-mysqladmin-to-change-the-root-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic POP3 &amp; IMAP Connection Testing via Telnet</title>
		<link>http://klkl.co.uk/2009/12/15/basic-pop3-imap-connection-testing-via-telnet/</link>
		<comments>http://klkl.co.uk/2009/12/15/basic-pop3-imap-connection-testing-via-telnet/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 14:16:01 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[pop3]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[telnet]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=237</guid>
		<description><![CDATA[<p><strong>To Test POP3</strong></p>
<p style="padding-left: 30px;">telnet <strong>xxx.xxx.xxx.xxx</strong> 110 (xxx = mailserver)<br />
<span style="color: #008000;">+OK Hello there.</span><br />
user <strong>USERNAME</strong><br />
<span style="color: #008000;">+OK Password required.</span><br />
pass <strong>PASSWORD<br />
</strong><span style="color: #008000;">+OK logged in.</span><br />
stat<br />
<span style="color: #008000;">+OK (Information about your mail)</span><br />
quit<br />
<span style="color: #008000;">+OK Bye-bye.</span></p>
<p><span id="more-237"></span><strong>To Test IMAP</strong></p>
<p style="padding-left: 30px;">telnet <strong>xxx.xxx.xxx.xxx</strong> 143<br />
<span style="color: #008000;">* OK (welcome message)</span><br />
a login <strong>USERNAME PASSWORD<br />
</strong><span style="color: #008000;">a OK login Ok.</span><br />
a examine inbox<br />
<span style="color: #008000;">(Information about mail)</span><br />
a logout<br />
<span style="color: #008000;">a OK LOGOUT completed</span></p>
<p><strong>To Test POP3 over SSL</strong></p>
<p style="padding-left: 30px;">openssl s_client -connect <strong>xxx.xxx.xxx.xxx</strong>:995<br />
Commands as above</p>
<p><strong>To Test IMAP over SSL</strong></p>
<p style="padding-left: 30px;">openssl s_client -connect <strong>xxx.xxx.xxx.xxx</strong>:993<br />
Commands as above</p>
]]></description>
			<content:encoded><![CDATA[<p><strong>To Test POP3</strong></p>
<p style="padding-left: 30px;">telnet <strong>xxx.xxx.xxx.xxx</strong> 110 (xxx = mailserver)<br />
<span style="color: #008000;">+OK Hello there.</span><br />
user <strong>USERNAME</strong><br />
<span style="color: #008000;">+OK Password required.</span><br />
pass <strong>PASSWORD<br />
</strong><span style="color: #008000;">+OK logged in.</span><br />
stat<br />
<span style="color: #008000;">+OK (Information about your mail)</span><br />
quit<br />
<span style="color: #008000;">+OK Bye-bye.</span></p>
<p><span id="more-237"></span><strong>To Test IMAP</strong></p>
<p style="padding-left: 30px;">telnet <strong>xxx.xxx.xxx.xxx</strong> 143<br />
<span style="color: #008000;">* OK (welcome message)</span><br />
a login <strong>USERNAME PASSWORD<br />
</strong><span style="color: #008000;">a OK login Ok.</span><br />
a examine inbox<br />
<span style="color: #008000;">(Information about mail)</span><br />
a logout<br />
<span style="color: #008000;">a OK LOGOUT completed</span></p>
<p><strong>To Test POP3 over SSL</strong></p>
<p style="padding-left: 30px;">openssl s_client -connect <strong>xxx.xxx.xxx.xxx</strong>:995<br />
Commands as above</p>
<p><strong>To Test IMAP over SSL</strong></p>
<p style="padding-left: 30px;">openssl s_client -connect <strong>xxx.xxx.xxx.xxx</strong>:993<br />
Commands as above</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2009/12/15/basic-pop3-imap-connection-testing-via-telnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Indent XML Quickly</title>
		<link>http://klkl.co.uk/2009/07/14/how-to-indent-xml-quickly/</link>
		<comments>http://klkl.co.uk/2009/07/14/how-to-indent-xml-quickly/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 19:42:51 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Pharmacy]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[dm+d]]></category>
		<category><![CDATA[indent]]></category>
		<category><![CDATA[libxml]]></category>
		<category><![CDATA[nhsbsa]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=189</guid>
		<description><![CDATA[<p>I&#8217;ve recently registered for accesss to the NHS&#8217;s dictionary of medicines and devices (dm+d). This was primarily to see what format the data was stored in and then to see if there was a way of utilising it in a cool webapp.</p>
<p>I downloaded the current release (its updated weekly) and unpacked the 5MB archive to reveal some XML and related files. Some of the files are huge (up to 32MB each and ~70MB in total) and there was no way a traditional program was going to mannage. I tried a few in fact and they all devastated my 2GB RAM and were generally unusable.</p>
<p>Time for a command line solution&#8230; VIM the open source text editor. Its extremely powerful and customisable but using it takes a little getting used to. VIM was able to open with only a slight delay and navigate these huge files. The next problem for me was being able to read them.</p>
<p>In theory it shouldn&#8217;t matter what indenting there is in an XML file as it doesn&#8217;t contain any data but I find its a lot easier to read the files if they&#8217;re &#8216;cleanly&#8217; indented. I began wondering how I was going to solve the problem and thought of a few ideas&#8230; a script (PERL, PHP, shell, other&#8230;) but none of those came to fruition. After some searching I came across <a href="http://xmlsoft.org/">libxml</a>.</p>
<p>You can download and compile from source if you wish but I decided to download a pre-built version from <a href="http://www.explain.com.au/oss/libxml2xslt.html">explain.com</a> it was pretty good and another page I came across on <a href="http://www.entropy.ch/blog/Developer/2008/04/23/XML-Pretty-Printing-in-BBEdit-and-vi-With-xmllint.html">entropy.ch</a> explained how to use it within Vim to indent my files super quick.</p>
<p>Here&#8217;s what you do&#8230;</p>
<ul>
<li>To format type this sequence
<ul>
<li>:%!xmllint &#8211;format -</li>
</ul>
</li>
<li>Or mark the area visually and then type
<ul>
<li>!xmllint &#8211;format -</li>
</ul>
</li>
</ul>
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently registered for accesss to the NHS&#8217;s dictionary of medicines and devices (dm+d). This was primarily to see what format the data was stored in and then to see if there was a way of utilising it in a cool webapp.</p>
<p>I downloaded the current release (its updated weekly) and unpacked the 5MB archive to reveal some XML and related files. Some of the files are huge (up to 32MB each and ~70MB in total) and there was no way a traditional program was going to mannage. I tried a few in fact and they all devastated my 2GB RAM and were generally unusable.</p>
<p>Time for a command line solution&#8230; VIM the open source text editor. Its extremely powerful and customisable but using it takes a little getting used to. VIM was able to open with only a slight delay and navigate these huge files. The next problem for me was being able to read them.</p>
<p>In theory it shouldn&#8217;t matter what indenting there is in an XML file as it doesn&#8217;t contain any data but I find its a lot easier to read the files if they&#8217;re &#8216;cleanly&#8217; indented. I began wondering how I was going to solve the problem and thought of a few ideas&#8230; a script (PERL, PHP, shell, other&#8230;) but none of those came to fruition. After some searching I came across <a href="http://xmlsoft.org/">libxml</a>.</p>
<p>You can download and compile from source if you wish but I decided to download a pre-built version from <a href="http://www.explain.com.au/oss/libxml2xslt.html">explain.com</a> it was pretty good and another page I came across on <a href="http://www.entropy.ch/blog/Developer/2008/04/23/XML-Pretty-Printing-in-BBEdit-and-vi-With-xmllint.html">entropy.ch</a> explained how to use it within Vim to indent my files super quick.</p>
<p>Here&#8217;s what you do&#8230;</p>
<ul>
<li>To format type this sequence
<ul>
<li>:%!xmllint &#8211;format -</li>
</ul>
</li>
<li>Or mark the area visually and then type
<ul>
<li>!xmllint &#8211;format -</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2009/07/14/how-to-indent-xml-quickly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Tunnel Connections Over SSH</title>
		<link>http://klkl.co.uk/2008/12/30/how-to-tunnel-connections-over-ssh/</link>
		<comments>http://klkl.co.uk/2008/12/30/how-to-tunnel-connections-over-ssh/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 19:24:07 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[tunnel]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=131</guid>
		<description><![CDATA[<p>I&#8217;ve been doing some work involving an application that needs to query databases on separate servers however one of the servers will only accept mysql connections locally so the way round it is to forward connections from a port on one system to a port on a remote system. That way the connection to the remote database will appear as though it originated locally and be accepted.</p>
<p>To set up a tunneled connection you issue the following command on any client:</p>
<p style="padding-left: 30px;"><strong>ssh -fNg -L 3307:127.0.0.1:3306 myuser@remotehost.com</strong></p>
<p>The first command tells ssh to log in to remotehost.com as myuser, go into the background (-f) and not execute any remote command (-N), and set up port-forwarding (-L localport:localhost:remoteport ). In this case, we forward port 3307 on localhost to port 3306 on remotehost.com.</p>
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing some work involving an application that needs to query databases on separate servers however one of the servers will only accept mysql connections locally so the way round it is to forward connections from a port on one system to a port on a remote system. That way the connection to the remote database will appear as though it originated locally and be accepted.</p>
<p>To set up a tunneled connection you issue the following command on any client:</p>
<p style="padding-left: 30px;"><strong>ssh -fNg -L 3307:127.0.0.1:3306 myuser@remotehost.com</strong></p>
<p>The first command tells ssh to log in to remotehost.com as myuser, go into the background (-f) and not execute any remote command (-N), and set up port-forwarding (-L localport:localhost:remoteport ). In this case, we forward port 3307 on localhost to port 3306 on remotehost.com.</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2008/12/30/how-to-tunnel-connections-over-ssh/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Applescript &amp; SMS Server Tools</title>
		<link>http://klkl.co.uk/2008/08/10/applescript-sms-server-tools/</link>
		<comments>http://klkl.co.uk/2008/08/10/applescript-sms-server-tools/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 18:48:08 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Applescript]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Kmail]]></category>
		<category><![CDATA[Mail]]></category>
		<category><![CDATA[SMS Server Tools]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=53</guid>
		<description><![CDATA[<p>I&#8217;ve set up <a title="SMS Server Tools 3" href="http://smstools3.kekekasvi.com/" target="_blank">SMS Server Tools</a> on my Mac Mini so that I can send text messages from my PC and I thought someone might be able to use the Applescript I&#8217;ve created or even suggest a better way of doing things.</p>
<p>If you&#8217;re not familiar with SMS Server Tools it&#8217;s a really great utility for sending text messages from your PC (I use the term generically) it works on (almost?) all UNIXs and Windows too. It works by having folders which it monitors for text message files and then sending them via the phone. It was very easy to set up just download the source, make, make install, edit the config file and away you go.</p>
<p><span id="more-53"></span>I set it up so I could send myself text alerts when I get new emails. I did have it set up last year on my Gentoo machine and I used a bash script to process mail passed from Kmail. This time I&#8217;m using my Mac Mini and OS X with Apple&#8217;s Mail and a bit of applescript.</p>
<p>The biggest difference between the way Kmail and Mac Mail does things is that Kmail would run the bash script each time a message matched a given rule. Mail passes a collection of messages to the applescript that match the rule.</p>
<p><strong>SMS File Format</strong></p>
<p>The SMS files are just plain text files with unique file names;</p>
<p style="padding-left: 30px;">To: 447xxxxxxxxx</p>
<p style="padding-left: 30px;">Message Text goes here</p>
<p>Notice how the phone number you&#8217;re sending the message to is international format without the leading + and that there is a blank line inbetween the number and the message text.</p>
<p><strong>The Applescript</strong></p>
<p>This is the applescript I&#8217;m using to send the messages. I don&#8217;t have much experience with Applescript so anyone who can see a better way of doing things (especially the writing of the file) then I&#8217;d appreciate some feedback.</p>
<p style="padding-left: 30px;"><span style="color: #808080;"> using terms from application &#8220;Mail&#8221;<br />
on perform mail action with messages theMessages<br />
repeat with theMessage in theMessages &#8212; loop through the messages sent by Mail<br />
&#8211;Extract the desired details<br />
set theSubject to subject of theMessage<br />
set theSender to extract address from (sender of theMessage)<br />
set MessageRecipients to get recipients of theMessage<br />
set firstRecipient to item 1 of MessageRecipients<br />
set toAddress to ((address of firstRecipient) as string)</span></p>
<p style="padding-left: 30px;"><span style="color: #808080;">&#8211;Create the randomly named file<br />
set dir_prefix to &#8220;~/sms/&#8221;<br />
set the_file to do shell script &#8220;mktemp &#8221; &amp; dir_prefix &amp; &#8220;tempfiles/XXXXXX&#8221;</span></p>
<p style="padding-left: 30px;"><span style="color: #808080;">&#8211;Output the message<br />
do shell script &#8220;echo To: <strong>447xxxxxxxxx</strong> &gt; &#8221; &amp; the_file<br />
do shell script &#8220;echo  &gt;&gt; &#8221; &amp; the_file<br />
do shell script &#8220;echo From: &#8221; &amp; quoted form of theSender &amp; &#8221; &gt;&gt; &#8221; &amp; the_file<br />
do shell script &#8220;echo To: &#8221; &amp; quoted form of toAddress &amp; &#8221; &gt;&gt; &#8221; &amp; the_file<br />
do shell script &#8220;echo Subject: &#8221; &amp; quoted form of theSubject &amp; &#8221; &gt;&gt; &#8221; &amp; the_file</span></p>
<p style="padding-left: 30px;"><span style="color: #808080;">&#8211;Move the text message to the spool directory<br />
do shell script &#8220;mv &#8221; &amp; the_file &amp; &#8221; &#8221; &amp; dir_prefix &amp; &#8220;outgoing/&#8221;<br />
end repeat<br />
end perform mail action with messages<br />
end using terms from</span></p>
<p>You can download the script from <a href="http://klkl.co.uk/wp-content/uploads/2008/08/sms-alert-script.scpt">here</a>. You will need to change the directory variables to suit your setup and you&#8217;ll need to replace the mobile number with the one you wish to send the messages to. I decided to edit my /etc/smsd.conf to define the spool folders to be in my home directory.</p>
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve set up <a title="SMS Server Tools 3" href="http://smstools3.kekekasvi.com/" target="_blank">SMS Server Tools</a> on my Mac Mini so that I can send text messages from my PC and I thought someone might be able to use the Applescript I&#8217;ve created or even suggest a better way of doing things.</p>
<p>If you&#8217;re not familiar with SMS Server Tools it&#8217;s a really great utility for sending text messages from your PC (I use the term generically) it works on (almost?) all UNIXs and Windows too. It works by having folders which it monitors for text message files and then sending them via the phone. It was very easy to set up just download the source, make, make install, edit the config file and away you go.</p>
<p><span id="more-53"></span>I set it up so I could send myself text alerts when I get new emails. I did have it set up last year on my Gentoo machine and I used a bash script to process mail passed from Kmail. This time I&#8217;m using my Mac Mini and OS X with Apple&#8217;s Mail and a bit of applescript.</p>
<p>The biggest difference between the way Kmail and Mac Mail does things is that Kmail would run the bash script each time a message matched a given rule. Mail passes a collection of messages to the applescript that match the rule.</p>
<p><strong>SMS File Format</strong></p>
<p>The SMS files are just plain text files with unique file names;</p>
<p style="padding-left: 30px;">To: 447xxxxxxxxx</p>
<p style="padding-left: 30px;">Message Text goes here</p>
<p>Notice how the phone number you&#8217;re sending the message to is international format without the leading + and that there is a blank line inbetween the number and the message text.</p>
<p><strong>The Applescript</strong></p>
<p>This is the applescript I&#8217;m using to send the messages. I don&#8217;t have much experience with Applescript so anyone who can see a better way of doing things (especially the writing of the file) then I&#8217;d appreciate some feedback.</p>
<p style="padding-left: 30px;"><span style="color: #808080;"> using terms from application &#8220;Mail&#8221;<br />
on perform mail action with messages theMessages<br />
repeat with theMessage in theMessages &#8212; loop through the messages sent by Mail<br />
&#8211;Extract the desired details<br />
set theSubject to subject of theMessage<br />
set theSender to extract address from (sender of theMessage)<br />
set MessageRecipients to get recipients of theMessage<br />
set firstRecipient to item 1 of MessageRecipients<br />
set toAddress to ((address of firstRecipient) as string)</span></p>
<p style="padding-left: 30px;"><span style="color: #808080;">&#8211;Create the randomly named file<br />
set dir_prefix to &#8220;~/sms/&#8221;<br />
set the_file to do shell script &#8220;mktemp &#8221; &amp; dir_prefix &amp; &#8220;tempfiles/XXXXXX&#8221;</span></p>
<p style="padding-left: 30px;"><span style="color: #808080;">&#8211;Output the message<br />
do shell script &#8220;echo To: <strong>447xxxxxxxxx</strong> &gt; &#8221; &amp; the_file<br />
do shell script &#8220;echo  &gt;&gt; &#8221; &amp; the_file<br />
do shell script &#8220;echo From: &#8221; &amp; quoted form of theSender &amp; &#8221; &gt;&gt; &#8221; &amp; the_file<br />
do shell script &#8220;echo To: &#8221; &amp; quoted form of toAddress &amp; &#8221; &gt;&gt; &#8221; &amp; the_file<br />
do shell script &#8220;echo Subject: &#8221; &amp; quoted form of theSubject &amp; &#8221; &gt;&gt; &#8221; &amp; the_file</span></p>
<p style="padding-left: 30px;"><span style="color: #808080;">&#8211;Move the text message to the spool directory<br />
do shell script &#8220;mv &#8221; &amp; the_file &amp; &#8221; &#8221; &amp; dir_prefix &amp; &#8220;outgoing/&#8221;<br />
end repeat<br />
end perform mail action with messages<br />
end using terms from</span></p>
<p>You can download the script from <a href="http://klkl.co.uk/wp-content/uploads/2008/08/sms-alert-script.scpt">here</a>. You will need to change the directory variables to suit your setup and you&#8217;ll need to replace the mobile number with the one you wish to send the messages to. I decided to edit my /etc/smsd.conf to define the spool folders to be in my home directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2008/08/10/applescript-sms-server-tools/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Help My Phone Won&#8217;t Charge! &#8211; Here&#8217;s the Solution</title>
		<link>http://klkl.co.uk/2008/08/10/help-my-phone-wont-charge-heres-the-solution/</link>
		<comments>http://klkl.co.uk/2008/08/10/help-my-phone-wont-charge-heres-the-solution/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 23:46:17 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Battery]]></category>
		<category><![CDATA[Charge]]></category>
		<category><![CDATA[Discharge]]></category>
		<category><![CDATA[Motorolla]]></category>
		<category><![CDATA[Nokia]]></category>
		<category><![CDATA[Phone]]></category>
		<category><![CDATA[SMS]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=46</guid>
		<description><![CDATA[<p>A while ago I had an old Nokia N-95 plugged into a Gentoo box and I was using <a title="SMS Server Tools" href="http://smstools.meinemullemaus.de/" target="_blank">SMS Server Tools</a> to send myself text message alerts. I got rid of that sim and so stopped using it. The phone has been sat in a drawer since then along with a couple of others.</p>
<p>I recently decided I wanted to set it all up again, this time on my Mac Mini. I was trying out different phones and settings but I couldn&#8217;t get the N95 or an old Motorola V series phone to do anything even after plugging them both in!<span id="more-46"></span></p>
<p>I suspected that the phones had been left alone for so long that the batteries had discharged to such a state that the phones could not charge them anymore. I did a bit of searching on Google and someone suggested using an old USB cable to charge the battery a bit before charging it normally.</p>
<p>I immediately scrounged round my room looking for an old USB cable to hack up and found a Motorolla  one. Here&#8217;s what to do;</p>
<ol>
<li>I got some pliers and stripped the phone end off, then stripped the wires back.</li>
<li>Make sure the <span style="color: #ff0000;"><strong>RED</strong></span> and <strong>BLACK</strong> wires do not touch each other!</li>
<li>Plug the USB cable in and connect the wires to the battery terminals as follows;
<ul>
<li>Touch the <strong>BLACK</strong> wire to the <strong>NEGATIVE</strong> terminal of the battery</li>
<li>Touch the <span style="color: #ff0000;"><strong>RED</strong></span> wire to the <span style="color: #ff0000;"><strong>POSITIVE</strong></span> terminal of the battery</li>
</ul>
</li>
<li>Hold the wires to the battery terminals for about 20 &#8211; 40 seconds (This step may need to be repeated to attain enough charge for the phone to take over)</li>
<li>Plug the battery back into the phone and plug in the charger as normal</li>
</ol>
<p>This worked for both my Nokia BL-5C battery and my Motorolla BC60 battery (this one took a few goes) now I&#8217;ve got them both charging. I&#8217;m going to hang on to my hacked up USB cable who knows when it may come in useful, that and I don&#8217;t like throwing computey stuffs out.</p>
]]></description>
			<content:encoded><![CDATA[<p>A while ago I had an old Nokia N-95 plugged into a Gentoo box and I was using <a title="SMS Server Tools" href="http://smstools.meinemullemaus.de/" target="_blank">SMS Server Tools</a> to send myself text message alerts. I got rid of that sim and so stopped using it. The phone has been sat in a drawer since then along with a couple of others.</p>
<p>I recently decided I wanted to set it all up again, this time on my Mac Mini. I was trying out different phones and settings but I couldn&#8217;t get the N95 or an old Motorola V series phone to do anything even after plugging them both in!<span id="more-46"></span></p>
<p>I suspected that the phones had been left alone for so long that the batteries had discharged to such a state that the phones could not charge them anymore. I did a bit of searching on Google and someone suggested using an old USB cable to charge the battery a bit before charging it normally.</p>
<p>I immediately scrounged round my room looking for an old USB cable to hack up and found a Motorolla  one. Here&#8217;s what to do;</p>
<ol>
<li>I got some pliers and stripped the phone end off, then stripped the wires back.</li>
<li>Make sure the <span style="color: #ff0000;"><strong>RED</strong></span> and <strong>BLACK</strong> wires do not touch each other!</li>
<li>Plug the USB cable in and connect the wires to the battery terminals as follows;
<ul>
<li>Touch the <strong>BLACK</strong> wire to the <strong>NEGATIVE</strong> terminal of the battery</li>
<li>Touch the <span style="color: #ff0000;"><strong>RED</strong></span> wire to the <span style="color: #ff0000;"><strong>POSITIVE</strong></span> terminal of the battery</li>
</ul>
</li>
<li>Hold the wires to the battery terminals for about 20 &#8211; 40 seconds (This step may need to be repeated to attain enough charge for the phone to take over)</li>
<li>Plug the battery back into the phone and plug in the charger as normal</li>
</ol>
<p>This worked for both my Nokia BL-5C battery and my Motorolla BC60 battery (this one took a few goes) now I&#8217;ve got them both charging. I&#8217;m going to hang on to my hacked up USB cable who knows when it may come in useful, that and I don&#8217;t like throwing computey stuffs out.</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2008/08/10/help-my-phone-wont-charge-heres-the-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Daylight Savings Error When Dealing With Timestamps</title>
		<link>http://klkl.co.uk/2008/07/10/php-daylight-savings-error-when-dealing-with-timestamps/</link>
		<comments>http://klkl.co.uk/2008/07/10/php-daylight-savings-error-when-dealing-with-timestamps/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 20:44:11 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Kquestion]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[BST]]></category>
		<category><![CDATA[DST]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Timestamp]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=42</guid>
		<description><![CDATA[<p>Last night I was working on determining how long a user had been logged into a PHP application but was having a problem with subtracting timestamps and this is how I solved it.</p>
<p>I was storing two timestamps (as a UNIX timestamp) in the database. One designating the date-time the user logged into the application and the other the date-time of the last activity the user performed. Because I was using UNIX timestamps, which are just the number of seconds sine the UNIX epoch, I subtracted one from the other and used that difference as the input to the PHP function date().</p>
<p>I couldn&#8217;t for the life of me work out why the date function was saying that I was logged in for an hour longer than I should have been and it was driving me crazy. It turns out that the reason was that my timezone locale setting in PHP is &#8216;Europe/London&#8217; and that this causes the date function to adjust for British Summer Time (GMT + 1) thus when I used my timestamp difference in the date() function it translated the difference into a readable format but also added an extra hour.</p>
<p>The solution is to use gmdate() which is identical to the date() function except that the time returned is in Grenwich Mean Time format.</p>
]]></description>
			<content:encoded><![CDATA[<p>Last night I was working on determining how long a user had been logged into a PHP application but was having a problem with subtracting timestamps and this is how I solved it.</p>
<p>I was storing two timestamps (as a UNIX timestamp) in the database. One designating the date-time the user logged into the application and the other the date-time of the last activity the user performed. Because I was using UNIX timestamps, which are just the number of seconds sine the UNIX epoch, I subtracted one from the other and used that difference as the input to the PHP function date().</p>
<p>I couldn&#8217;t for the life of me work out why the date function was saying that I was logged in for an hour longer than I should have been and it was driving me crazy. It turns out that the reason was that my timezone locale setting in PHP is &#8216;Europe/London&#8217; and that this causes the date function to adjust for British Summer Time (GMT + 1) thus when I used my timestamp difference in the date() function it translated the difference into a readable format but also added an extra hour.</p>
<p>The solution is to use gmdate() which is identical to the date() function except that the time returned is in Grenwich Mean Time format.</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2008/07/10/php-daylight-savings-error-when-dealing-with-timestamps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

