<?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>Rick's Awesome Blog &#187; Update</title>
	<atom:link href="http://www.richardosgood.com/blog/category/update/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.richardosgood.com/blog</link>
	<description>(Not) Just another WordPress weblog</description>
	<lastBuildDate>Sun, 05 Apr 2009 12:23:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Pneumatic Cannon</title>
		<link>http://www.richardosgood.com/blog/2008/08/26/pneumatic-cannon/</link>
		<comments>http://www.richardosgood.com/blog/2008/08/26/pneumatic-cannon/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 18:52:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Project]]></category>
		<category><![CDATA[Update]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[cannon]]></category>
		<category><![CDATA[coil]]></category>
		<category><![CDATA[gun]]></category>
		<category><![CDATA[pneumatic]]></category>
		<category><![CDATA[potato]]></category>

		<guid isPermaLink="false">http://rickspbx.dyndns.org:81/blog/?p=53</guid>
		<description><![CDATA[I&#8217;ve wanted to build a potato cannon since I was in high school, but never really got around too it.  About two years ago I finally built one with my friend Drake.  It was a very basic cannon.  It had about a four foot long barrel and two inches wide, with a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve wanted to build a potato cannon since I was in high school, but never really got around too it.  About two years ago I finally built one with my friend Drake.  It was a very basic cannon.  It had about a four foot long barrel and two inches wide, with a three inch wide chamber at the bottom.  We would spray some hairspray in there and ignite it with a grill igniter.  It worked pretty well but I was always a bit concerned with the fire element.  Since then I have read up on using compressed air to build more powerful pneumatic potato cannons.  I finally decided to spend some money and get the parts to build one.</p>
<p>I was able to find most of what I needed at Lowe&#8217;s.  I bought all the PVC there, a PSI gauge, and a hacksaw.  I ended up having to go to Ace Hardware to get the Schrader valve.  One of the guys that works at Ace Hardware instantly knew what I was building when I told him I was attaching the valve to PVC.  It turns out he has built a few of these himself.  He advised me to use caulking to seal up the valve and PSI gauge to the PVC.</p>
<p>Once I returned home to my apartment I laid out all the pieces to make sure I hadn&#8217;t forgotten anything.  It was at this time that I had realized the 3&#8243; Sch40 PVC I had purchased to function as the pressure tank says right on the side of it &#8220;FOR NONPRESSURE USE ONLY&#8221;.  Great.  It turns out this Lowe&#8217;s doesn&#8217;t carry PVC pressure pipe in any sizes over 2&#8243;.  I also tried the nearest Home Depot with no success.  I will be stopping by a bigger Home Depot today to try and find some.  Once I have the pipe, I can start chopping, drilling, and gluing everything into place.  I&#8217;m hoping to have this thing ready by Sunday so I can launch some potatoes into orbit.</p>
<p>I&#8217;m adding a page for this to the Works in Progress section.  I&#8217;m also adding a page to the ideas section for a coil gun.  While doing research for the air cannon I found many resources on building a small coil gun out of used disposable cameras.  I&#8217;ll most likely be stopping by a CVS soon to try and score some.  There are actually several ideas I have for the disposable cameras but the coil gun sounds the most intriguing to me right now.  I&#8217;ll be posting updates as things roll along.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardosgood.com/blog/2008/08/26/pneumatic-cannon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Project Completed</title>
		<link>http://www.richardosgood.com/blog/2008/05/22/new-project-compelted/</link>
		<comments>http://www.richardosgood.com/blog/2008/05/22/new-project-compelted/#comments</comments>
		<pubDate>Thu, 22 May 2008 22:05:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Project]]></category>
		<category><![CDATA[Update]]></category>
		<category><![CDATA[anniversary]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sx]]></category>

		<guid isPermaLink="false">http://rickspbx.dyndns.org:81/blog/?p=52</guid>
		<description><![CDATA[It&#8217;s been a while since I posted on here.  There are several reasons for that.  The main reason is that my latest project has been taking all my spare time and it was a secret.  I didn&#8217;t log any of it until just a few minutes ago because I didn&#8217;t want the [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I posted on here.  There are several reasons for that.  The main reason is that my latest project has been taking all my spare time and it was a secret.  I didn&#8217;t log any of it until just a few minutes ago because I didn&#8217;t want the secret to get out.  It is an anniversary present for my girlfriend.  You can check out the project page for more details on that.</p>
<p>The second reason is that my web server has been down and I haven&#8217;t fixed it until recently.  My server rebooted one day when I lost power and Apache refused to start for some reason.  Rather than sitting down to fix that, I just spent all my time working on the anniversary project.  It turns out there was some other instance of httpd running in the background hogging port 81.  I have no idea why this was.  I&#8217;ll have to reboot the system again to see if the problem occurs again.  At least I&#8217;ll know what the problem is.</p>
<p>In other news, I have started the Near Space class at school last week.  I am really excited for this class.  We will be sending a balloon equipped with computer, science experiments, and a camera into near space in just a few months.  Ryan is splitting the class into teams and should have them posted on the e-shell this weekend at some point.  Hopefully I&#8217;ll have access to the shell soon.  I just e-mailed a local enthusiast to see if he wants to come to class to share his experiences and offer some words of wisdom.  Hopefully that will go over well.</p>
<p>My dad should be sending me another radio, antenna and a Tiny Trak 3 module next week.  I can&#8217;t wait to get that stuff.  I want to start messing with APRS tracking as soon as possible to get a feel for it before we actually do a launch.  I&#8217;m hoping to be on the tracking and telemetry team for the near space class.</p>
<p>I suppose that&#8217;s enough updating for now.  I have to take some photos of the anniversary lamp to stick on that page, as well as get a schematic up.  Man, I still need to get a schematic up on the graduation hacks page&#8230;  I&#8217;ll get on that soon.  I&#8217;ll also post a video of the lamp in action.  Until then.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardosgood.com/blog/2008/05/22/new-project-compelted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Please, God let me finish this tonight</title>
		<link>http://www.richardosgood.com/blog/2008/05/05/please-god-let-me-finish-this-tonight/</link>
		<comments>http://www.richardosgood.com/blog/2008/05/05/please-god-let-me-finish-this-tonight/#comments</comments>
		<pubDate>Mon, 05 May 2008 21:24:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Update]]></category>

		<guid isPermaLink="false">http://rickspbx.dyndns.org:81/blog/?p=50</guid>
		<description><![CDATA[I really want to get this radio playlist finished tonight.  I&#8217;m sick of fighting with it.  I was thinking earlier that the best way to deal with the e-mail deletion option might just be to open up the mail again at the end of the program, cycle through all of the e-mails again, [...]]]></description>
			<content:encoded><![CDATA[<p>I really want to get this radio playlist finished tonight.  I&#8217;m sick of fighting with it.  I was thinking earlier that the best way to deal with the e-mail deletion option might just be to open up the mail again at the end of the program, cycle through all of the e-mails again, and delete them at that time.  It&#8217;s not elegant but it will do&#8230; hopefully.</p>
<p>That didn&#8217;t work either.  I could not figure out for the life of me what the problem was when it dawned on me.  I had placed a print statement towards the end of the program that should always be called, but it wasn&#8217;t.  That&#8217;s when I discovered where the problem was.  The Perl script just halted at the exec command.  It would run the shell command and then just freeze for some reason.  I tried changing it to the system() function and it worked!.  I got rid of all the extra stuff I just added and tested out the delete function.  It works!  Now that means all I should have to do is change the delay time back to 30 minutes and test this baby out.</p>
<p>I turned on the radio at 9:14 and the song Never There by Cake was playing.  I love that band.  I send a text message to my e-mail towards the beginning of the song.  I checked my at jobs a few minutes later and lo and behold, a job was set for 30 minutes from now.  So far, all is going well.  I just need to check back in 30 minutes to see if the song shows up.  If it does, I&#8217;ll consider this project finished until I find some problems that need to be fixed.</p>
<p>Thirty minutes pass, I check for the playlist file and it exists.  It&#8217;s the moment of truth.  Does it give me the Aritst Cake and the Song Never There?  Yes!  Finally I have this thing working.  I can start something new now.  I&#8217;m going to go update the project page right now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardosgood.com/blog/2008/05/05/please-god-let-me-finish-this-tonight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OK let&#8217;s do this</title>
		<link>http://www.richardosgood.com/blog/2008/05/04/ok-lets-do-this/</link>
		<comments>http://www.richardosgood.com/blog/2008/05/04/ok-lets-do-this/#comments</comments>
		<pubDate>Sun, 04 May 2008 21:11:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Update]]></category>

		<guid isPermaLink="false">http://rickspbx.dyndns.org:81/blog/?p=48</guid>
		<description><![CDATA[If watching Iron Man last night has made me realize anything, it&#8217;s that I need to finish this radio playlist project so I can start building my own arc reactor.  I&#8217;ve been spending all my time as of late destroying GTA4 and it&#8217;s time to get back to work.  So let&#8217;s DO THIS!
When I [...]]]></description>
			<content:encoded><![CDATA[<p>If watching Iron Man last night has made me realize anything, it&#8217;s that I need to finish this radio playlist project so I can start building my own arc reactor.  I&#8217;ve been spending all my time as of late destroying GTA4 and it&#8217;s time to get back to work.  So let&#8217;s DO THIS!</p>
<p>When I last left off, there was something weird happening with the bash script.  For some reason the at job would start it, but it would have problems.  Since it&#8217;s running in the background and there&#8217;s no logging going on, I have no idea what the problem is.  The first thing I&#8217;m doing today is adding some logging features.  I&#8217;ll just have it echo some stuff out to a file in the same directory so I can see what&#8217;s going on.</p>
<p>So I&#8217;ve added some logging lines and I&#8217;ve also altered the Perl script to add the at job immediately instead of waiting 30 minutes.  This change is only temporary.  I don&#8217;t want to have to wait 30 minutes for each test.  Now I just wait 3 minutes for the cron job to start and we&#8217;ll see what happens.</p>
<p>Well that didn&#8217;t work.  No log was created.  This means that either none of the logging lines ran at all, or I have to give the full path to where the log is.  I&#8217;m not sure.  I&#8217;ll try adding the full path and see what happens after that.</p>
<p>That didn&#8217;t work either.  It seems like nothing is happening at all.  I&#8217;m going to try to set the at job manually and see what happens.</p>
<p>That seems to have started working&#8230; but not completed.  AHA!  The log shows that the the script is not getting the input arguments.  It seems like at has no way of providing arguments.  I tried using double quotes and single quotes around the entire command to no avail.  I&#8217;m not really sure how to handle this problem.  I need a way of  sending the time to the bash script but I&#8217;m not sure if &#8216;at&#8217; can do it.  Also, it&#8217;s really hard to do a Google search for &#8216;at&#8217; so I&#8217;m not sure how to find that out&#8230; Perhaps my handy dandy ginormous Unix manual has something to say about this&#8230;  Not really.</p>
<p>I figured it out!  Thanks to <a href="http://www.oreilly.com/catalog/debian/chapter/book/ch13_03.html">this page</a> I found.  I can send arguments to the at command by calling it like this:</p>
<p><em>echo &#8220;command arg1 arg2 arg3&#8243; | at -t time</em></p>
<p>I tested it out and it works.  Now I can just change the Perl script to reflect this and we shall see what happens.</p>
<p>That fixed THAT problem.  Finally.  Although now there are more problems.  Luckily, the at command sends mail to my user when something goes wrong.  Based on the error messages I received, I forgot to include the full path to the downloaded html code.  I changed that and everything finally works!  Now I have to figure out why the emails are not being deleted when I set them to be.</p>
<p>I&#8217;m having trouble figuring this out.  It only deletes the e-mails if I put the Delete command before the IF statements.  However this makes it so the IF statements do not work at all.  I&#8217;m taking a break from this for the rest of the night.  Until tomorrow&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardosgood.com/blog/2008/05/04/ok-lets-do-this/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Radio Playist is starting to piss me off</title>
		<link>http://www.richardosgood.com/blog/2008/04/30/the-radio-playist-is-starting-to-piss-me-off/</link>
		<comments>http://www.richardosgood.com/blog/2008/04/30/the-radio-playist-is-starting-to-piss-me-off/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 22:14:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Update]]></category>

		<guid isPermaLink="false">http://rickspbx.dyndns.org:81/blog/?p=47</guid>
		<description><![CDATA[Now that I have the main script working, I need to be able to receive email notifications.  This is where I am stuck.  I cannot for the life of me find a console based mail client that will allow this.  All of the clients require a user to control them.  This [...]]]></description>
			<content:encoded><![CDATA[<p>Now that I have the main script working, I need to be able to receive email notifications.  This is where I am stuck.  I cannot for the life of me find a console based mail client that will allow this.  All of the clients require a user to control them.  This is driving me nuts.  I have tried a <a href="http://www.adp-gmbh.ch/perl/net/pop3.html">perl script</a> that I found and that didn&#8217;t seem to work.  I thought about trying to use links with a defined command set but I don&#8217;t think that will work either.</p>
<p>I&#8217;m starting to think maybe I can set up my own e-mail server.  Maybe I can have the mail server perform an action (run a script) when it receives certain e-mails.  One problem I have with this is that my ISP (Cox) seems to <a href="http://www.oit.ucsb.edu/CHSI.asp">block access to port 25</a>.  There seems to be a way around it if you have a valid MX record.  I went to my Domain Name provider and added an MX record for myself.  Now I think I should be able to route e-mail through Cox&#8217;s mail servers.  I&#8217;m not sure that I really need this, though.  They might only be blocking outbound e-mail and not inbound.  I can&#8217;t figure it out.</p>
<p>Screw it.  I&#8217;m just going to go for it and see what happens.  I&#8217;m installing <a href="http://www.google.com/url?sa=t&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fwww.postfix.org%2F&amp;ei=E8IYSObJM4HUpgTMi_iGCQ&amp;usg=AFQjCNGsDJwzM5BP7gbHlMDnjqUCdOlpBw&amp;sig2=ybBByagPLU-5TqjYLYkfPg">postfix</a> on my server and I&#8217;m going to try to get all of this working.</p>
<p>I started out following <a href="http://www.hughesjr.com/content/view/14/">this guide</a>, but it includes a lot of other programs I don&#8217;t need.  I don&#8217;t want anti virus or spam protection or anything like that.  I just want a really basic mail server.</p>
<p>OK.  So I&#8217;ve spent several hours trying to figure out how the heck to solve this problem and I think I&#8217;ve finally found my <a href="http://rasterweb.net/raster/code/src/gmailpop_pl.txt">answer</a>.  It is a Perl script written specifically to retrieve e-mail messages from GMail accounts.  Before it would run on my system I had to install two Perl modules using cpan:</p>
<p><em>install Mail::POP3Client<br />
install IO::Socket::SSL</em></p>
<p>I saved the script to my computer, added execute permissions (chmod +x) and changed the variables to match my own g-mail account.  I ran the script and presto, I had my e-mail&#8230; finally.  I wish I had found this a lot sooner.  I also wish I was a better programmer.  So now, I have a way to use a script to retrieve my e-mail.  I just have to modify this script to locate any messages with only the word &#8220;Radio&#8221; as the subject, and then call my other script.</p>
<p>I have added a few lines of code to the script in order to test for the occurrence of the word &#8220;Radio&#8221; as well as to get the time that the e-mail message was sent.  The time is crucial in order to tell when the song was actually played.  The code I changed looks as follows:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-CODE&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p><em># loop over msgs</em></p>
<p><em>for($i = 1; $i &lt;= $pop-&gt;Count(); $i++) {</em></p>
<p><em>print $pop-&gt;Head($i) . &#8220;\n&#8221;; #Print out header info<br />
#print $pop-&gt;Body($i) . &#8220;\n&#8221;;<br />
if($pop-&gt;Head($i) =~ m/Radio/) { # If the header contaisn the word Radio anwhere<br />
print &#8220;Found Radio!\n&#8221;; # Tell me if found it<br />
if($pop-&gt;Head($i) =~ m/(\d\d):(\d\d):\d\d/) { # If the header contains a date<br />
print &#8220;Message Time: $1:$2\n&#8221;; # Print out the hour and minute<br />
}<br />
}<br />
print &#8220;\n&#8221;;<br />
</em>}</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;END CODE&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>So far, this works perfectly.  I can tell that the word radio is present.  If it finds it, it will grab the time and print it.  Now I just need to convert the time into a 12 hour format and save the hour, minute, and AM/PM setting in three variables.  Once they are saved, I can set a cron job to run 30 minutes from the current time to call my bash script with the variables as arguments.  The 30 minute delay is required because the playlist on the website does not get updated for anywhere between 10-30 minutes typically.  I&#8217;m off to work on a time conversion function.</p>
<p>So here&#8217;s my quick and dirty (probably terribly innefficient) time conversion program.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;CODE&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p># Function to convert time to 12 hour time.<br />
sub timeConvert {<br />
($hour1) = @_; # set these variables to = inputs<br />
print &#8220;timeConvert: $hour1\n&#8221;;<br />
if ($hour1 =~ &#8220;00&#8243;) { # if it&#8217;s midnight<br />
$hour2=&#8221;12&#8243;;  # change from 00 to 12<br />
$ap2=&#8221;AM&#8221;;    # set to AM<br />
return;<br />
}<br />
$hour1 += 0; # convert the string to int<br />
if ($hour1 &lt; 12) { # if its morning<br />
$ap2=&#8221;AM&#8221;; # set to am<br />
return;<br />
}<br />
if ($hour1 =~ 12) { # if its noon<br />
$ap2=&#8221;PM&#8221;;  # set to PM<br />
return;<br />
}<br />
if ($hour1 &gt; 12)  { # if it&#8217;s after noon<br />
print &#8220;Greater than 12\n&#8221;;<br />
$ap2=&#8221;PM&#8221;;  # set to pm</p>
<p>$hour2=$hour1 &#8211; 12; # convert to 12 hour format<br />
return;<br />
}<br />
return;<br />
}</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-END CODE&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>The function takes in an hour value and performs all of those checks on it.  Based on the time it will convert the hour value as necessary, and then set the AM/PM variable.  My next step will be to get this Perl script to call my bash script as soon as it sees a Radio message.  I will deal with setting the cron job later.</p>
<p>Well, that was easy.  One simple command did the trick.</p>
<p><em>exec &#8220;playlist.bash $hour2 $2 $ap2&#8243;;</em></p>
<p>I added this into the if condition that checks for a time in the email header.  This way, it won&#8217;t call the playlist script unless it finds a time and converts it first.  I sent a new text message to my g-mail account and ran the script.  Everything worked perfectly.  The only problem is that the time now is 4:35PM and the song it returned to me was played at 4:16 PM.  That&#8217;s the delay problem I was referring too before.  Now I have to get the script to wait 30 minutes before checking for the song.</p>
<p>First I had to fix my system to have the correct time and date:</p>
<p><em>date 04301637</em></p>
<p>That did the trick, but I just remembered my bash script has a fatal flaw that I should fix now before I forget about it.  If the song is played at the very beginning or end of the hour, the script does not take into consideration the fact that there are only 60 minutes in an hour.  It could potentially try to look for a song played at 2:60, which obviously would not exist.  I need to write a conversion function for the minute and hour for the bash script in this event.  I&#8217;ll do that next.</p>
<p>I had to add a whole bunch of nested if statements in order to get the job done.  When I say &#8220;had too&#8221; I really mean I&#8217;m not really sure the best way to do this and that&#8217;s the only way I could think of right now.  It looks really messy but it gets the job done.  The whole section looks like this:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;CODE&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>if [[ $artist = "" ]]  #&#8211;If we didn&#8217;t find an artist<br />
then                   #&#8211;Then increment the minute<br />
m=`expr $m + 1`<br />
if [[ $m = 60 ]]     #&#8211;Obviously we can&#8217;t check 2:60 oclock<br />
then<br />
h=`expr $h + 1`   #increment the hour and<br />
m=00               # change the minute<br />
if [[ $h = 12 ]]  # might need to toggle AM PM<br />
then<br />
if [[ $a = "AM" ]]<br />
then<br />
a=&#8221;PM&#8221;<br />
else<br />
a=&#8221;AM&#8221;<br />
fi<br />
c=1<br />
fi<br />
fi<br />
if [[ $h = 13 ]]     # Now we also need to check for the hour being too high<br />
then<br />
h=1<br />
fi<br />
echo &#8220;time: $h:$m $a&#8221;<br />
artist=`cat savedPage.html | grep &#8220;&gt;$h:$m $a&#8221; -A 1 | tail -n1 | sed &#8217;s/&lt;td nowrap&gt;&lt;span class=blackMain11px&gt;//&#8217; | sed &#8217;s/&lt;\/td&gt;/\n/&#8217; | head -n1`<br />
if [[ $artist = "" ]] # if the artist still has not been found<br />
then                  # then set the time back to normal<br />
if [[ $c = 1 ]] # if we changed the am/pm setting<br />
then            # then reset it<br />
a=$3<br />
c=0<br />
fi<br />
h=$1<br />
m=$2<br />
fi<br />
fi</p>
<p>while [[ $artist = "" ]] #&#8211;If we didn&#8217;t find an artist<br />
do                       # then continue to subtract a minute till we find one<br />
m=`expr $m &#8211; 1`<br />
if [[ $m = -1 ]]     #&#8211;Obviously we can&#8217;t check 2:-1 oclock<br />
then<br />
h=`expr $h &#8211; 1`   #decrement the hour and<br />
m=59               # change the minute<br />
if [[ $h = 0 ]]  # Need to change from 0:00 to 12:00<br />
then<br />
h=11<br />
fi<br />
if [[ $h = 11 ]] # this is where we might need to toggle AM/PM<br />
then<br />
if [[ $m = 59 ]]<br />
then<br />
if [[ $a = "AM" ]]<br />
then<br />
a=&#8221;PM&#8221;<br />
else<br />
a=&#8221;AM&#8221;<br />
fi<br />
fi<br />
fi<br />
fi<br />
if [[ $h = 13 ]]     # Now we also need to check for the hour being too high<br />
then<br />
h=1<br />
fi<br />
fi<br />
if [[ $m -lt 10 ]]     # the earlier correction stuff makes anything&lt;0 look like: 12:1 instead of 12:01.  We have to add that zero<br />
then<br />
m=&#8221;0$m&#8221;<br />
fi<br />
echo &#8220;time: $h:$m $a&#8221;<br />
artist=`cat savedPage.html | grep &#8220;&gt;$h:$m $a&#8221; -A 1 | tail -n1 | sed &#8217;s/&lt;td nowrap&gt;&lt;span class=blackMain11px&gt;//&#8217; | sed &#8217;s/&lt;\/td&gt;/\n/&#8217; | head -n1`<br />
done</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-END CODE&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>Ah, god it hurts to look at.  I really should switch this whole thing over to Perl.  Why I don&#8217;t just quit now and do that I don&#8217;t know.  At least it&#8217;s all set now.</p>
<p>OK, I think I&#8217;ve fixed that problem but I just discovered another one I had not even thought of before.  If I try to search for the time 12:03, it MAY return a song that was actually played at 2:03 because it doesn&#8217;t check the value before that number.  I&#8217;m going to have to fix my grep search string.</p>
<p>That turned out to be WAY easier than I expected.  The way the playlist html code is set up, there is always a &#8216;&gt;&#8217; character right before the time value.  All I had to do was add that to the beginning of my grep search.  It now looks like this:</p>
<p><em>artist=`cat savedPage.html | grep &#8220;&gt;$h:$m $a&#8221; -A 1 | tail -n1 | sed &#8217;s/&lt;td nowrap&gt;&lt;span class=blackMain11px&gt;//&#8217; | sed &#8217;s/&lt;\/td&gt;/\n/&#8217; | head -n1`</em></p>
<p>Piece of cake.  Now what&#8217;s left from here?  The time delay.  What is the best way for me to do this?  I suppose I&#8217;ll have the perl script constantly running in the background, checking my e-mail every five minutes for a new message.  If it finds the message, I&#8217;ll have it set a cron job to run 30 minutes from the current time.  The cron job will call the bash script, which will then save the artist and song title to a file on my system.  I also have to delete the messages after I&#8217;ve read them to prevent me from reading them over and over again.</p>
<p>I&#8217;m going to start with having the script set the cron job.  According to <a href="http://www.unixgeeks.org/security/newbie/unix/cron-1.html">this reference article</a> cron takes 24 hour time.  This should be easier for me considering the g-mail time comes in as a 24-hour time.</p>
<p>And apparently cron is used when you want a job to run more than once.  That is, every day, week, month, etc.  What I want to use is the &#8220;At&#8221;command.  I found <a href="http://www.ibm.com/developerworks/library/l-job-scheduling.html">this nice reference</a> for the at command.  at also takes a 24 hour time, so I need to set up a new function in the perl script to come up with the future time, and set the at job.</p>
<p>Holy crap.  So I just did some googling for the heck of it and <a href="http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html">discovered</a> that I can actually just use the date command to get the date in the future.  In my case I can just run:</p>
<p><em>date &#8211;date=&#8217;30 minutes&#8221;</em></p>
<p>This tells me the time 30 minutes from now.  The at command wants to take a date in the form &#8220;mmddhhmm&#8221;.  I should be able to just output the date command in that format and pipe it to the at command.  This is going to be so much easier than I thought.  I love Linux!</p>
<p>So I added a new perl function:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-CODE&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p># Function to get the curent time and set an at job in 30 minutes<br />
sub setJob {<br />
my $future = `date &#8211;date=&#8217;30 minutes&#8217; -t +%m%d%H%M`;<br />
print &#8220;future= $future&#8221;;<br />
exec &#8220;at -f ./playlist.bash -t $future&#8221;;<br />
return;<br />
}</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-END CODE&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>And I set it to be called where I used to have the perl script directly call the bash script.  Now I just have to set the bash script to save all songs saved into a file.  To do this, I deleted the end of the bash script where it printed the song to the screen and replaced it with this:</p>
<p><em>#&#8212;&#8212;Save the artist and song&#8212;&#8212;<br />
date=`date +%m-%d-%Y` # det todays date so we can start a list for all songs found today<br />
echo &#8220;$artist &#8211; $song&#8221; &gt;&gt; /media/radioLists/$date # save song in file</em></p>
<p>This creates a text file with the name being equal to todays date.  That way I can have a list for every day I find a song.  It saves the lists in my media directory which is shared via Samba.</p>
<p>I guess all that is left is to get the Perl script to check my mail every five minutes and set up GMail to delete the messages I have already read.  I think the easiest way to do this would be to just set cron jobs.  I can set up one cron job for every five minutes of an hour.  Those jobs will run every hour, daily.</p>
<p>I also noticed that although I set up GMail to delete my messages once they are accessed with POP, it isn&#8217;t working.  I added a line into my Perl script to set each Radio message to be deleted.</p>
<p>Now it&#8217;s testing time.  I switched on the Radio and hear &#8220;Linkin Park&#8217;s &#8211; What I&#8217;ve done&#8221;.  That was at 6:30.  I sent a text message to my e-mail address while the song was playing.  Now I have to wait until 6:35 to see if the cron job will actually start and if my Perl script will actually set the at job correctly.  If all goes according to plan,  I should basically be finished with this project.</p>
<p>The time has come.  My Radio e-mail has dissapeared so that&#8217;s a good sign.  The cron jobs are working.  Now did the at job get set?  No.  There was a problem or two with the script.  For one, it took me about 20 minutes to figure out that the message was actually being deleting before I got the time from it.  I had to move the Delete command to a later spot in the Perl script.  Second, the Perl script needed an absolute path to the bash script for the AT command.  Once I fixed that, it all seems to work.</p>
<p>I turned on the radio at 7:37 and the song Psycho was playing by Puddle of Mudd.  The script was delayed due to the problems I mentioned in the last paragraph, but it will run.  I&#8217;m waiting for 7:19PM to find out if this thing will actually work.  If yes, then I am done until I find a problem.  Or if I decide to port the entire thing to Perl, which would be a really good idea.  We&#8217;ll see&#8230;</p>
<p>Nope.  It didn&#8217;t work.  I can&#8217;t figure this out.  It look like cron actually runs the Perl script and the Perl script sets an at job.  I noticed that since I moved the pop-&gt;Delete(); command to a different place it&#8217;s stopped working, but the real problem is that the bash script doesn&#8217;t seem to be functioning properly.  The AT job starts, but then never finishes.  I can see all the Grep, Sed, Tail, etc processes using &#8220;ps -A&#8221; but they all say &lt;Defunct&gt;.  They keep disappearing and re-appearing.  I&#8217;m starting to wonder if the Perl script isn&#8217;t creating the AT job correctly for some reason.  Although, both scripts work fine if I run them myself&#8230;  MY friend Brian suggested that I give all commands in my bash script absolute paths.  I&#8217;ve tried that and it does the same thing.  The script works fine when I call it myself but not when the at process calls it.  I can&#8217;t figure this out.  I was thinking maybe I have to give Perl all of the absolute paths as well, but if it&#8217;s actually setting an at job than that couldn&#8217;t be the problem.  I&#8217;m really at a loss here.</p>
<p>Tomorrow I&#8217;ll probably have to start adding some kind of logging features.  Also, since Perl seems to be working fine maybe I&#8217;ll just start porting the Bash code over to Perl.  It couldn&#8217;t hurt I suppose&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardosgood.com/blog/2008/04/30/the-radio-playist-is-starting-to-piss-me-off/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Radio Playlist Work</title>
		<link>http://www.richardosgood.com/blog/2008/04/29/radio-playlist-work/</link>
		<comments>http://www.richardosgood.com/blog/2008/04/29/radio-playlist-work/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 18:59:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Update]]></category>

		<guid isPermaLink="false">http://rickspbx.dyndns.org:81/blog/?p=46</guid>
		<description><![CDATA[So, I was going to try to get the VU Meter Tie project going again, only I decided to put the LEDs on the buttons of my shirt instead of in a tie.  Unfortunately I destroyed four surface mount LEDs while trying to solder wires or leads to them.  I&#8217;m either going to [...]]]></description>
			<content:encoded><![CDATA[<p>So, I was going to try to get the VU Meter Tie project going again, only I decided to put the LEDs on the buttons of my shirt instead of in a tie.  Unfortunately I destroyed four surface mount LEDs while trying to solder wires or leads to them.  I&#8217;m either going to need slightly bigger LEDs or some tiny wire.  Out of frustration I&#8217;ve decided to come work on the Radio Playlist project instead.</p>
<p>Where I last <a href="http://rickspbx.dyndns.org:81/blog/2008/04/26/radio-playlist-is-coming-along-famously/">left off</a>, I now have a script that can retrieve the Artist and Song title of a song played on the Edge at a specified time.  I would run the script like this:</p>
<p><em>./script2.bash 6:28\ PM</em></p>
<p>Running this exact command right now returns the result:</p>
<p><em>FINGER ELEVEN<br />
Paralyzer</em></p>
<p>So, all is well in the script so far.  Now everything gets trickier.  For one, the website doesn&#8217;t update the songs in real time.  When a song is played on the radio, it won&#8217;t show up on the list for around 10-30 minutes.  30 minutes is the maximum delay that I have noticed so far.  This means that when the script receives a notice to check for the song, it will have to wait about 30 minutes before actually checking.  My first reaction is to schedule a cron job to call the script 30 minutes after it receives the message from me.  This means that I will actually need two scripts.  One to check for the e-mails and set the cron job, and another to actually look up the song and save it in a list.</p>
<p>The next trick lies in the fact that my computer time is not synchronized with the radio station&#8217;s time.  Therefore, my computer will see that I want a song that was being played at say, 3:14.  The radio station&#8217;s playlist might say it was played at 3:12 or 3:16.  My script has to have some way of finding the right time, without going too far and getting the wrong song.  I think if the script first looks up the exact time  on my computer and finds nothing, then it can increment by one minute and check again.  It will go up a maximum of two minutes.  If it finds nothing, than it will start subtracting one minute from my computer&#8217;s time until it finds a song.  The first song it encounters will be considered the correct song.  This is the first thing I will work on today.</p>
<p>So I have added a bit to the script and I&#8217;m beginning to think a different programming language would have been a better choice.  Perl maybe?  I&#8217;m not sure.  I&#8217;m just going to keep on moving with bash until I feel i have to change environments.  Here is the newer, revised version of the script:</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;CODE&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>#Next 3 lines are temp for testing the script<br />
#They take the input values and store them in variables (h=hour, m=minute, a=am/pm)</p>
<p>h=$1<br />
m=$2<br />
a=$3</p>
<p>echo &#8220;time: $h:$m&#8221;</p>
<p>#&#8212;&#8211;Get the page and save it to a file<br />
curl http://www.mediabase.com/whatsong/whatsong.asp?var_s=075069068074045070077 &gt; savedPage.html</p>
<p>#&#8212;&#8211;Get the Artist&#8212;&#8212;-<br />
artist=`cat savedPage.html | grep &#8220;$h:$m $a&#8221; -A 1 | tail -n1 | sed &#8217;s/&lt;td nowrap&gt;&lt;span class=blackMain11px&gt;//&#8217; | sed &#8217;s/&lt;\/td&gt;/\n/&#8217; | head -n1`</p>
<p>if [[ $artist = "" ]]  #&#8211;If we didn&#8217;t find an artist<br />
then                   #&#8211;Then increment the minute<br />
m=`expr $m + 1`<br />
echo &#8220;time: $h:$m $a&#8221;<br />
artist=`cat savedPage.html | grep &#8220;$h:$m $a&#8221; -A 1 | tail -n1 | sed &#8217;s/&lt;td nowrap&gt;&lt;span class=blackMain11px&gt;//&#8217; | sed &#8217;s/&lt;\/td&gt;/\n/&#8217; | head -n1`<br />
fi</p>
<p>while [[ $artist = "" ]] #&#8211;If we didn&#8217;t find an artist<br />
do<br />
m=`expr $m &#8211; 1`<br />
echo &#8220;time: $h:$m $a&#8221;<br />
artist=`cat savedPage.html | grep &#8220;$h:$m $a&#8221; -A 1 | tail -n1 | sed &#8217;s/&lt;td nowrap&gt;&lt;span class=blackMain11px&gt;//&#8217; | sed &#8217;s/&lt;\/td&gt;/\n/&#8217; | head -n1`<br />
done</p>
<p>#&#8212;&#8211;Get the Song&#8212;&#8212;&#8212;<br />
song=`cat savedPage.html | grep &#8220;$h:$m $a&#8221; -A 1 | tail -n1 | sed &#8217;s/D&gt;&lt;td nowrap&gt;&lt;span class=blackMain11px&gt;/\n/&#8217; | tail -n1 | sed &#8217;s/&lt;\/td&gt;/\n/&#8217; | head -n1`</p>
<p>#&#8212;&#8212;Print the artist and song&#8212;&#8212;<br />
echo $artist<br />
echo $song</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;END CODE&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>The first change I did was to take the input time and save the values into variables.  I then use those variables to search for the time within the html code instead of the raw input values.  This allows me to change the values easily if I need too.</p>
<p>The next addition is the &#8220;if&#8221; condition.  This says that if the $artist variable is empty (we didn&#8217;t find anything for that time) then add one minute to the time and check THAT time.</p>
<p>The next change is the &#8220;while&#8221; loop.  This loop checks to see if the $artist variable is blank again.  If it is still blank, then it decrements the time by one minute and checks THAT time.  It will continue to decrement and check the time until it finds a song.  This works, but I think it MIGHT end up working better if I check one minute up, then one minute down, then two minutes up, then two minutes down, etc.  This would allow me to find the closest song to the current time.</p>
<p>The last change I made was to have it save the artist and the song title into two variables.  This was to make it easier to check them.  At the end of the loop I just echo the variable values.</p>
<p>Now that this part of the script is working, it&#8217;s time to write a new script to check for an e-mail message.  I&#8217;m thinking I&#8217;ll probably use <a href="http://www.washington.edu/pine/getpine/linux.html">pine</a>, since it seems to be a popular console-based e-mail client.</p>
<p>So after trying to get pine installed for a while I had no luck.  I kept needed dependencies and not knowing where to get them or how to install them.  I ended up finding <a href="http://www.centos.org/modules/newbb/viewtopic.php?topic_id=13650&amp;forum=38">this little guide</a> on installing alpine by using yum and rpmforge.  I followed it and it seems to have worked.  Now I just need to figure out how to set it up to check my <a href="http://www.gmail.com">GMail</a> account.</p>
<p>I found <a href="http://jaysonrowe.wordpress.com/2008/03/24/how-to-set-up-alpine-with-gmail-via-imap/">this tutorial</a> on how to set up alpine to read messages from Gmail.  Not very difficult at all.  Now that I can view my e-mail with alpine, I still have no idea how to use this in a script.  I&#8217;m beginning to think that I can&#8217;t.  It looks like there must be a user issuing commands to Alpine in such a way that doesn&#8217;t allow for scripting.</p>
<p>I found <a href="http://www.adp-gmbh.ch/perl/net/pop3.html">this perl script</a> for checking an email account for unwanted messages and then deleting them.  The script checks the subject line.  If all it contains is the word &#8220;Document&#8221; then it attempts to delete the message.  This is similar to what I want to do, only instead of just deleting the message, I want to trigger an event and then delete it.</p>
<p>OK it&#8217;s late and I suppose I&#8217;m done for the night.  I have tomorrow off, except for the last final exam I&#8217;ll ever have to take&#8230; ever.  So hopefully I can get this working tomorrow.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardosgood.com/blog/2008/04/29/radio-playlist-work/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Radio Playlist is coming along famously</title>
		<link>http://www.richardosgood.com/blog/2008/04/26/radio-playlist-is-coming-along-famously/</link>
		<comments>http://www.richardosgood.com/blog/2008/04/26/radio-playlist-is-coming-along-famously/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 20:29:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Update]]></category>

		<guid isPermaLink="false">http://rickspbx.dyndns.org:81/blog/?p=45</guid>
		<description><![CDATA[I found some more time to add in the details of my progress on the radio playlist project.  I&#8217;ve decided once again that the original information I included on that page should probably have been a blog post.  I have removed it and replaced it with something more suitable.  The text that [...]]]></description>
			<content:encoded><![CDATA[<p>I found some more time to add in the details of my progress on the radio playlist project.  I&#8217;ve decided once again that the original information I included on that page should probably have been a blog post.  I have removed it and replaced it with something more suitable.  The text that used to be there is included at the end of this blog post just so I&#8217;ll have it, and also so I do not have to explain the whole thing over again.  For now, here is the progress I have made so far:</p>
<p>The first thing I had to do was find a way to download the web page to my computer from the command line.  Having used <a href="http://curl.haxx.se/">cURL</a> before, it seemed like an obvious answer.  The problem I ran into first, was that I didn&#8217;t know the URL of the actual playlist page.  The way I normally got to it was by visiting the <a href="hhttp://www.theedge1039.com/">Edge&#8217;s website</a>, clicking on the &#8220;Edge Music&#8221; button, and then selecting the &#8220;What song was that?&#8221; option.  The URL for the page supposedly showed up in my address bar, but it was incorrect.  I could not for the life of me figure out the URL to the playlist page.  Then my friend gave me a great idea.  Use <a href="http://www.wireshark.org/">Wireshark</a> to see what exactly happens when I click on the link.  That was the answer to this problem.  Wireshark revealed that the URL to the playlist is:</p>
<p><a href="http://www.mediabase.com/whatsong/whatsong.asp?var_s=075069068074045070077">http://www.mediabase.com/whatsong/whatsong.asp?var_s=<br />
075069068074045070077</a></p>
<p>It appears that The Edge uses another company called MediaBase to handle the playlist for them.  Regardless, I had the URL.  Now it was time to get cURL to download the page.  This is a piece of cake.  The command is simply:</p>
<p><em>curl http://www.mediabase.com/whatsong/whatsong.asp?var_s=<br />
075069068074045070077</em></p>
<p>Done.  The code to the page is dumped to the screen.  Now that I had a way to get the page locally, I needed a way to get rid of all the html code and just get the Artist and Title that corresponds to a specific time.  I figured the best way to start was to use good old grep.  I chose a random time that was available on the playlist and tried piping the curl command to it:</p>
<p><em>curl http://www.mediabase.com/whatsong/whatsong.asp?var_s=<br />
075069068074045070077 | grep &#8220;11:30 AM&#8221;</em></p>
<p>It worked&#8230; almost.  The line containing the time was returned to me, although it appears that the time for one song is actually included on the previous line.  This means that when I find the line that contains the time for the song I want, I actually need to get the next line to see the artist and song title.  The only way I could figure out how to get the line returned with grep was to run the command:</p>
<p><em>curl http://www.mediabase.com/whatsong/whatsong.asp?var_s=<br />
075069068074045070077 | grep &#8220;11:30 AM&#8221; -A 1</em></p>
<p>The -A 1 argument tells grep to return the matching line, and one extra line after that.  So now I had the artist and the title, but all this other html garbage as well.   Since I didn&#8217;t need the first line that contained the time, I figured the next logical step was to get rid of it.  I only wanted the second line returned by grep.  How did I do it?  Like this:</p>
<p><em>curl http://www.mediabase.com/whatsong/whatsong.asp?var_s=<br />
075069068074045070077 | grep &#8220;11:30 AM&#8221; -A 1 | tail -n1</em></p>
<p>This command gets the web page, pipes the output to grep which returns the line containing the time, and the next line that contains the artist name and song title.  Then it pipes those two lines of output to the tail command.  The &#8220;tail -n1&#8243; command shows the last &#8220;n&#8221; lines of whatever I pipe to it.  In my case, n=1.  Therefore, tail will cut out everything but the last line.</p>
<p>Now that I have only the line I need, I decided to use sed to parse out the information I wanted.  I found this <a href="http://www.grymoire.com/Unix/Sed.html">awesome tutorial</a> for sed during an earlier project and it proved to be a huge help with this project as well.  This part took me a while.  I&#8217;m not very good with sed but eventually a found a solution that worked for me.  I piped all the output from the first commands to this one:</p>
<p><em>sed &#8217;s/&lt;td nowrap&gt;&lt;span class=blackMain11px&gt;//&#8217;</em></p>
<p>This command finds the text &#8220;&lt;td nowrap&gt;&lt;span class=blackMain11px&gt;&#8221; (which is just some code in the page) and deletes it.  I then pipe that output to the command:</p>
<p><em>sed &#8217;s/&lt;\/td&gt;/\n/&#8217;</em></p>
<p>This command finds the first part in the text that matches &#8220;&lt;/td&gt;&#8221; and replaces it with the newline character (/n).  Why did I do this?  The first sed command removes everything before the artist name.  The second sed command splits the one line into two lines.  The first line will contain the artist name only.  The second line contains all of the html code that I don&#8217;t care about.  Now I can simply pipe that output to:</p>
<p><em>head -n1</em></p>
<p>The head command works opposite the tail command.  &#8220;head -n1&#8243; outputs the first &#8216;n&#8217; lines of the input.  In this case, n=1 so head outputs one line only.  The end result is the artist name and nothing else!  Now I just had to do something similar to retrieve the song name.  The full command I used for this was:</p>
<p><em>cat savedPage.html | grep &#8220;$1&#8243; -A 1 | tail -n1 | sed &#8217;s/D&gt;&lt;td<br />
nowrap&gt;&lt;span class=blackMain11px&gt;/\n/&#8217; | tail -n1 |<br />
sed &#8217;s/&lt;\/td&gt;/\n/&#8217; | head -n1</em></p>
<p>I won&#8217;t bother explaining this whole thing because it is the exact same idea as the last command.  The only difference is that I removed all of the text before the song title, and split the one line right after the song title.  I now have a way to retrieve the Artist name and Song title of any song as long as I know the time the song was played.  I then created a bash script to do all of this for me.  The script code looks like this:</p>
<p><em>#!/bin/bash</em></p>
<p><em>#&#8212;-The next three lines are to be used for checking the time in a later revision&#8212;-</em><em><br />
h=`date +%l`<br />
m=`date +%M`<br />
echo &#8220;time: $h:$m&#8221;<br />
</em></p>
<p><em>#&#8211;Get the web page and save in a file called &#8220;savedPage.html&#8221;</em><em><br />
curl http://www.mediabase.com/whatsong/whatsong.asp?var_s=075069068074045070077 &gt; savedPage.html</em></p>
<p><em>#&#8212;&#8211;Get the Artist&#8212;&#8212;-<br />
cat savedPage.html | grep &#8220;$1&#8243; -A 1 | tail -n1 | sed &#8217;s/&lt;td<br />
nowrap&gt;&lt;span class=blackMain11px&gt;//&#8217; | sed &#8217;s/&lt;\/td&gt;/\n/&#8217; | head -n1</em></p>
<p><em>#&#8212;&#8211;Get the Song&#8212;&#8212;&#8212;<br />
cat savedPage.html | grep &#8220;$1&#8243; -A 1 | tail -n1 | sed &#8217;s/D&gt;&lt;td<br />
nowrap&gt;&lt;span class=blackMain11px&gt;/\n/&#8217; | tail -n1 | sed &#8217;s/&lt;\/td&gt;/\n/&#8217; | head -n1</em></p>
<p>This script will simply output the artist name on one line, and the song title on the other line.  I saved the webpage to a file first to avoid having to retrieve it twice.  This lowers the run time of the script.</p>
<p>That&#8217;s all I have for now.  The next step should probably be to set up the script with a fudge factor.  It is very unlikely that my computer is set to the exact same time as the playlist computer&#8217;s clock.  This means that I will never have the exact time the song is played.  The script must look at the time I listened, and find song with the closest time.  Also, it takes about 20 minutes for the playlist to update after each song, so the script will have to hear my request, and then wait to retrieve the song.  After that, I will have to set up the e-mail portion of the script.  This is the part that will actually allow me to send a text to my computer.</p>
<p>So far I&#8217;m really happy with how fast this is coming along.  I expect it to be finished very soon.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;Previously found in the project section&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>I thought of this project a few days ago.  I was driving in my car and they played this new song on the radio (The Edge 103.9).  I loved it and wanted to find it on my computer when I got home to listen again, but I had missed the names of the song and band.  This happens a lot while driving.  Normally in that situation I will have to send a text message to myself of some lyrics that I remember so I can Google them later and try to find the song.  Well this project aims to prevent this problem.</p>
<p>I want to write a script that will sit on my server and look for incoming e-mails with a specific subject line coming from my cell phone.  When it finds one of these e-mails it will go to <a href="http://wwwtheedge1039.com">The Edge&#8217;s web site</a> and look at what song is playing at, or around, that time.  When it finds the artist and song title it will save that to a &#8220;playlist&#8221; of sorts.  I can then come home later and look at the list to see all of the songs I want to find.</p>
<p>The reason this should work is because The Edge keeps a list of all the songs that they play.  Every time they play a song, the list gets updated.  I&#8217;m thinking I can use Curl to check the website and Bash to do most of the other scripting.  Maybe I should use Perl instead to make it more portable?  We&#8217;ll see.  I&#8217;ve already started this project but I&#8217;ll post up my progress in a blog post later.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardosgood.com/blog/2008/04/26/radio-playlist-is-coming-along-famously/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Graduation Hacks Updated</title>
		<link>http://www.richardosgood.com/blog/2008/04/25/graduation-hacks-updated/</link>
		<comments>http://www.richardosgood.com/blog/2008/04/25/graduation-hacks-updated/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 22:41:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Update]]></category>

		<guid isPermaLink="false">http://rickspbx.dyndns.org:81/blog/?p=41</guid>
		<description><![CDATA[Ok so, I&#8217;ve graduated already and I completed this project.  I was so caught up with getting this project ready that I didn&#8217;t even bother to take photos of it or document anything until now.  I also had lots of homework and final projects to finish.  I still do, actually.  But [...]]]></description>
			<content:encoded><![CDATA[<p>Ok so, I&#8217;ve graduated already and I completed this project.  I was so caught up with getting this project ready that I didn&#8217;t even bother to take photos of it or document anything until now.  I also had lots of homework and final projects to finish.  I still do, actually.  But I have some more time to update so I am going to update the graduation hacks section right now.  Also, I realized that what was previously written in that section should have been posted as a blog post instead, so I&#8217;ve removed it from that section and included it below so I would still have all of that documented.  Time to go update!</p>
<p>Also, expect to see the VU meter tie project updated very soon as well.  I&#8217;ve decided to use my Tech Ninja shirt instead of a tie, but the idea is similar.  I will use red surface mountable LEDs on each button of the shirt.  Those buttons will act as the VU meter.  I will wear this shirt way more than I would ever wear a tie.   Plus, since I&#8217;m looking into learning a new microcontroller, perhaps I can update the circuit and make it smaller as well.  We&#8217;ll find out&#8230;</p>
<p>&#8212;&#8212;Below is what used to be written in the graduation hack section.&#8212;&#8212;&#8211;</p>
<p>I graduate on April 17, 2008 and today is April 3rd. I just received my cap and gown in the mail about 2 days ago. My teacher, Ryan, made me realize that I should modify my cap and/or gown in some way to make it my own. I&#8217;m inclined to agree. I&#8217;m not really sure what I want to do with it yet. I can&#8217;t quite come up with an idea I feel is good enough. A friend of mine is going to put a matrix of LEDs on his cap. So far the Ideas I have are:</p>
<p>1) A motor in the middle of the cap to make the tassels spin around.<br />
2) LEDs in the tassels.</p>
<p>It&#8217;s not much right now, but I&#8217;ll keep working on this.  I only have two weeks until graduation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardosgood.com/blog/2008/04/25/graduation-hacks-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Small Update</title>
		<link>http://www.richardosgood.com/blog/2008/04/23/small-update/</link>
		<comments>http://www.richardosgood.com/blog/2008/04/23/small-update/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 16:17:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Project]]></category>
		<category><![CDATA[Update]]></category>

		<guid isPermaLink="false">http://rickspbx.dyndns.org:81/blog/?p=37</guid>
		<description><![CDATA[I&#8217;m still really busy with trying to get all of my homework and final papers complete, but I wanted to throw up a few more links that helped me out with the VU Meter project.  I don&#8217;t want to lose them forever.  I should have time in a day or two to actually [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m still really busy with trying to get all of my homework and final papers complete, but I wanted to throw up a few more links that helped me out with the VU Meter project.  I don&#8217;t want to lose them forever.  I should have time in a day or two to actually put some real updates on here.  Until then, here are the links:</p>
<p><a href="http://www.epanorama.net/circuits/microphone_powering.html">How to power electret microphones</a></p>
<p><a href="hhttp://www.national.com/ds.cgi/LM/LM3914.pdf">LM3914 Datasheet</a></p>
<p><a href="http://zebu.uoregon.edu/~rayfrey/431/notes9.pdf">Op-Amp basics</a></p>
<p>Once I get some more time I will try to actually put these up on my own server instead of just linking to other sites.  Until next time&#8230;</p>
<p>Oh, and one more thing.  I&#8217;ve started working on a new project that I haven&#8217;t even posted anywhere on the site yet.  It&#8217;s basically a script that will watch for an e-mail and then jump onto The Edge 103.9&#8217;s web page to see what song is playing.  This way, when I&#8217;m driving my car, I can just text message my server and have it save a list of all the songs I like.  Then I can go find them later without having to write them down or try to remember them.  I&#8217;ll post up my progress on that later as well.  Ok, NOW I&#8217;m out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardosgood.com/blog/2008/04/23/small-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VU Meter Tie / Graduation Hacks Almost Complete!</title>
		<link>http://www.richardosgood.com/blog/2008/04/14/vu-meter-tie-graduation-hacks-almost-complete/</link>
		<comments>http://www.richardosgood.com/blog/2008/04/14/vu-meter-tie-graduation-hacks-almost-complete/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 00:25:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Update]]></category>

		<guid isPermaLink="false">http://rickspbx.dyndns.org:81/blog/?p=36</guid>
		<description><![CDATA[So,  I ended up decided to build the VU Meter Tie circuit and use it on my graduation gown, thus killing two birds with one stone.  I have been so completely busy this week with homework and trying to get this project finished before my family arrives on Wednesday that I haven&#8217;t posted any updates [...]]]></description>
			<content:encoded><![CDATA[<p>So,  I ended up decided to build the VU Meter Tie circuit and use it on my graduation gown, thus killing two birds with one stone.  I have been so completely busy this week with homework and trying to get this project finished before my family arrives on Wednesday that I haven&#8217;t posted any updates at all.  Also, I have an interview in the morning.  Hope that goes well.  Anyways, back to the topic at hand.  Hopefully tomorrow night I can post a video and some photos to show how truly awesome this thing is.  Until then&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardosgood.com/blog/2008/04/14/vu-meter-tie-graduation-hacks-almost-complete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
