<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Blojects</title>
	<atom:link href="http://bricej.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bricej.wordpress.com</link>
	<description>A blog about projects</description>
	<lastBuildDate>Tue, 19 Jan 2010 17:11:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='bricej.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Blojects</title>
		<link>http://bricej.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://bricej.wordpress.com/osd.xml" title="Blojects" />
	<atom:link rel='hub' href='http://bricej.wordpress.com/?pushpress=hub'/>
		<item>
		<title>From scripts to commands</title>
		<link>http://bricej.wordpress.com/2010/01/16/from-scripts-to-commands/</link>
		<comments>http://bricej.wordpress.com/2010/01/16/from-scripts-to-commands/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 08:18:42 +0000</pubDate>
		<dc:creator>bricej13</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux Shell]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[Symbolic Links]]></category>
		<category><![CDATA[bin]]></category>

		<guid isPermaLink="false">http://bricej.wordpress.com/?p=37</guid>
		<description><![CDATA[Have you ever written a script and wanted to be able to run it as a native command in the Linux terminal? We&#8217;re going to go through writing a script, changing permissions, and making a symbolic link so you can run it from anywhere. Where are my programs stored? Programs in Linux are stored in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bricej.wordpress.com&amp;blog=11337641&amp;post=37&amp;subd=bricej&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Have you ever written a script and wanted to be able to run it as a native command in the Linux terminal? We&#8217;re going to go through writing a script, changing permissions, and making a symbolic link so you can run it from anywhere.</p>
<p><strong>Where are my programs stored?</strong></p>
<p>Programs in Linux are stored in bin and sbin folders. sbin contains programs that can only be run by the super user. You have several of these folders spread out across your system that all have different privileges attached to them. Linux has a <code>$PATH</code> variable that stores all the places you can have programs that will run when typed into the terminal.</p>
<p>Try typing <code>$ echo $PATH</code> to see where they are.<br />
<code><br />
brice@brice-laptop:~$ echo $PATH<br />
/home/brice/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games<br />
</code><br />
The one we&#8217;ll be using today is the /home/username/bin folder. It&#8217;s unique for each user that they already have read/write permission to put their programs in.</p>
<p><strong>Sample Script</strong></p>
<p>My mom told me to be grateful so sometimes I&#8217;m really thankful when the terminal does what I ask. I try to tell it thanks but it has no idea what I&#8217;m talking about. Let&#8217;s fix this. Let&#8217;s start by navigating to the folder where your scripts are kept (make one if you don&#8217;t have one) making a script called thankyou.</p>
<p><code>brice@brice-laptop:~$ gedit thankyou<br />
</code><br />
In the new script type:</p>
<p><code>#!/bin/bash<br />
echo<br />
echo "You're Welcome!"<br />
echo</code></p>
<p>That&#8217;s easy enough to understand. Save it and close it. Back in the terminal type ./thankyou. &#8220;./&#8221; refers to the current directory and has to be placed before a script if you want to run it from the directory you&#8217;re in. You should get an error:</p>
<p><code>brice@brice-laptop:~/Scripts$ ./thankyou<br />
bash: ./thankyou: Permission denied</code></p>
<p>Wait, how can I not have permission, I just wrote the file? You do have permission, kinda. You have read/write permission. Execute permission is another animal all together. To get execute permission you must run the chmod command.<br />
<code><br />
brice@brice-laptop:~$ chmod 755 ./thankyou<br />
</code><br />
We&#8217;re getting close, try the following command:<br />
<code><br />
brice@brice-laptop:~$ ./thankyou</code></p>
<p><code> </code></p>
<p><code>You're Welcome!</code></p>
<p><code> </code><br />
That&#8217;s exciting! Now where ever you are in your file system you can thank the terminal by typing <code>/home/username/Scripts/thankyou</code>. That&#8217;s nice, but let&#8217;s take it one step further.</p>
<p><strong>Symbolic Links</strong></p>
<p>Symbolic links in Linux are similar to shortcuts in Windows. We could move our script to the /username/bin folder, but then we&#8217;d have to navigate there every time we wanted to edit the script. Instead let&#8217;s place a symbolic link there that refers to the original script. The command works like this:</p>
<p><code>ln [path to script] [path to link]<br />
</code><br />
So for us:</p>
<p><code>brice@brice-laptop:~/Scripts$ ln /home/brice/Scripts/thankyou /home/brice/bin/thankyou<br />
</code><br />
That&#8217;s it! Type thankyou into your console and appreciate the results!<br />
<code><br />
brice@brice-laptop:~/Scripts$ thankyou</code></p>
<p><code> </code></p>
<p><code>You're Welcome!</code></p>
<p><code> </code></p>
<p><strong>Further Information</strong></p>
<p>Here are some links to help you on your way:</p>
<p>Permissions, chmod: <a href="http://www.zzee.com/solutions/linux-permissions.shtml" target="_blank">http://www.zzee.com/solutions/linux-permissions.shtml</a></p>
<p>Shell scripts, chmod: <a href="http://linuxcommand.org/learning_the_shell.php" target="_blank">http://linuxcommand.org/learning_the_shell.php</a></p>
<p>Symbolic Links: <a href="http://www.nixtutor.com/freebsd/understanding-symbolic-links/" target="_blank">http://www.nixtutor.com/freebsd/understanding-symbolic-links/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bricej.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bricej.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bricej.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bricej.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bricej.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bricej.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bricej.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bricej.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bricej.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bricej.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bricej.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bricej.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bricej.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bricej.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bricej.wordpress.com&amp;blog=11337641&amp;post=37&amp;subd=bricej&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bricej.wordpress.com/2010/01/16/from-scripts-to-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/426d2a4d020359dac80a635ae5033e0e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bricej13</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby weather fetching script</title>
		<link>http://bricej.wordpress.com/2010/01/09/ruby-weather-fetching-script/</link>
		<comments>http://bricej.wordpress.com/2010/01/09/ruby-weather-fetching-script/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 21:23:31 +0000</pubDate>
		<dc:creator>bricej13</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Conky]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Weather]]></category>

		<guid isPermaLink="false">http://bricej.wordpress.com/?p=3</guid>
		<description><![CDATA[Use this Ruby script in your .conkyrc file, or use it to check the weather from the terminal.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bricej.wordpress.com&amp;blog=11337641&amp;post=3&amp;subd=bricej&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://bricej.files.wordpress.com/2010/01/screenshot.png"><img class="aligncenter size-full wp-image-13" title="Ruby Weather Script" src="http://bricej.files.wordpress.com/2010/01/screenshot.png?w=450&#038;h=190" alt="Example of weather script in action" width="450" height="190" /></a><br />
I&#8217;m on a quest to learn ruby. I&#8217;ve found it fantastically easier than C, C++, and Java: the languages I&#8217;ve primarily programmed in. This script can be used in conjunction with conky or alone.</p>
<p>This script grabs a weather XML file from Google, then parses the data and prints the relevant information, and sends a notification to the system. The XML contains much more information like a 5 day forecast that can be easily extracted with ruby.</p>
<p>Create a new file called weather.rb (or whatever you want) and paste the code. To run navigate to the directory in the terminal and type</p>
<p><code>$ ruby weather.rb</code></p>
<p>You may have noticed in the screenshot that I ran the program by just typing in &#8216;weather&#8217;. I&#8217;ll have a tutorial on this soon.</p>
<p>Add this to <strong>conky </strong>using the following code:</p>
<p><code>${execi 600 ~/Scripts/weather.rb}</code></p>
<p>Don&#8217;t forget to change the location to where you have saved the &#8216;weather.rb&#8217; file. This will check the weather every 600 seconds, or 10 minutes. To keep the notification from showing you only have to comment the last line of code (before <code>end </code>of course) using #. That will disable the <code>notify-send</code> command.</p>
<p><code><br />
#!/usr/bin/ruby<br />
require 'rexml/document'<br />
require 'open-uri'</code></p>
<p><code>open('http://www.google.com/ig/api?weather=provo,ut') do |weather_input|  #change location in URL<br />
xml = REXML::Document.new(weather_input)</code></p>
<p><code>xml.elements.each("xml_api_reply/weather/forecast_information/city") do |el|<br />
@location = "#{el.attributes['data']}" if el.attributes['data']<br />
end</code></p>
<p><code>xml.elements.each("xml_api_reply/weather/current_conditions/temp_f") do |el|<br />
@temperature = "#{el.attributes['data']}" if el.attributes['data']<br />
end</code></p>
<p><code>xml.elements.each("xml_api_reply/weather/current_conditions/condition") do |el|<br />
@condition = "#{el.attributes['data']}" if el.attributes['data']<br />
end</code></p>
<p><code>xml.elements.each("xml_api_reply/weather/current_conditions/wind_condition") do |el|<br />
@wind = "#{el.attributes['data']}" if el.attributes['data']<br />
length = @wind.length-6<br />
@wind = @wind[6,length]<br />
end</p>
<p>xml.elements.each("xml_api_reply/weather/current_conditions/humidity") do |el|<br />
@humidity = "#{el.attributes['data']}" if el.attributes['data']<br />
length = @humidity.length-10<br />
@humidity = @humidity[10,length]<br />
end</p>
<p>notify_location = "\"#{@location}\""<br />
puts "Location:\t" &lt;&lt; @location<br />
puts "Temperature:\t" &lt;&lt; @temperature &lt;&lt; "F"<br />
puts "Condition:\t" &lt;&lt; @condition<br />
puts "Wind:\t\t" &lt;&lt; @wind<br />
puts "Humidity:\t" &lt;&lt; @humidity<br />
line_two = "\"" &lt;&lt; @temperature &lt;&lt; "F\t\t\t" &lt;&lt; @condition &lt;&lt; "\n" &lt;&lt; @wind &lt;&lt; "\t" &lt;&lt; @humidity &lt;&lt; " humidity" &lt;&lt; "\""<br />
`notify-send  #{notify_location} #{line_two}`  #Comment this line to disable notifications</p>
<p>end</p>
<p></code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bricej.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bricej.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bricej.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bricej.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bricej.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bricej.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bricej.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bricej.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bricej.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bricej.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bricej.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bricej.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bricej.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bricej.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bricej.wordpress.com&amp;blog=11337641&amp;post=3&amp;subd=bricej&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bricej.wordpress.com/2010/01/09/ruby-weather-fetching-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/426d2a4d020359dac80a635ae5033e0e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bricej13</media:title>
		</media:content>

		<media:content url="http://bricej.files.wordpress.com/2010/01/screenshot.png" medium="image">
			<media:title type="html">Ruby Weather Script</media:title>
		</media:content>
	</item>
	</channel>
</rss>
