<?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>Technique</title>
	<atom:link href="http://www.joabj.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.joabj.com/blog</link>
	<description>Exploring the internal workings of information technology.</description>
	<lastBuildDate>Sat, 01 Dec 2012 18:33:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>Fun with PHP data types</title>
		<link>http://www.joabj.com/blog/?p=1168</link>
		<comments>http://www.joabj.com/blog/?p=1168#comments</comments>
		<pubDate>Thu, 02 Feb 2012 13:39:57 +0000</pubDate>
		<dc:creator>joabj</dc:creator>
				<category><![CDATA[data types]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.joabj.com/blog/?p=1168</guid>
		<description><![CDATA[All About PHP data types]]></description>
			<content:encoded><![CDATA[<p>All data stored by PHP is put into one of eight different types of buckets, technically called <strong>data types</strong>.  The data type determines what operations can be carried out on that piece of data. </p>
<p>Four of the data types are scalar&#8211;they support only a single value. These are <strong>integer</strong> (a whole number),<strong> float</strong> (a number with a decimal point), <strong>string</strong> (a sequence of symbols) and <strong>boolean</strong> (0 or 1). </p>
<p>PHP also has two compound data types. One is an <strong>array</strong>, or a bounded collection of multiple values. The other is an <strong>object</strong>, or a collection of data that also contains properties and methods. Finally, PHP has two special data types. One is a <strong>resource</strong>, which is a reference to some external data source. The other, <strong>null</strong>, has only one value, null. </p>
<p>PHP is a <strong>loosely typed</strong> language, meaning the variables do not need to have their data types defined before they are used. If you code $sample = 4.5; then PHP will assume the the $sample variable is a floating point data type. It is totally up to you to make sure that you pass the correct data type to any operation (i.e. don&#8217;t ask PHP to multiply two text strings). </p>
<p>That said, PHP offers some tools to help get a handle on all your loose data types. PHP&#8217;s <strong>gettype()</strong> function can let you know what type of data type the provided variable is, i.e. gettype( $sample ). You can also change a data type with PHP <strong>settype()</strong>, i.e. settype ( $sample, &#8220;integer&#8221;) will return the value of 4. PHP tries to preserve as much of the original value as possible during the conversion process. </p>
<p>Finally, you can set a variable&#8217;s type even before it is assigned a value. This is called <strong>type casting</strong>. Here you place the name of the data type, in parenthesis, before the name of the variable. So &#8220;(float) $sample = 4.5&#8243; will ensure that the $sample variable will be a floating point data type.</p>
<p><i>From the book<br />
<center><br />
<iframe src="http://rcm.amazon.com/e/cm?t=httpwwwjoabjc-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0470413964&#038;ref=qf_sp_asin_til&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe><br />
</center><br />
All mistakes are my own, however&#8230;-Joab Jackson</i></p>
<p><!-- Google Ads --></p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-0956514146719150";
/* Blog Ad */
google_ad_slot = "3094432839";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- End Google Ads --></p>
<p><!-- Google Analytics--></p>
<p><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><br />
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3825357-2");
pageTracker._trackPageview();
} catch(err) {}</script><br />
<!--End Google analytics --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joabj.com/blog/?feed=rss2&#038;p=1168</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript&#8217;s Document Object Model (DOM)</title>
		<link>http://www.joabj.com/blog/?p=1132</link>
		<comments>http://www.joabj.com/blog/?p=1132#comments</comments>
		<pubDate>Thu, 20 Oct 2011 12:59:59 +0000</pubDate>
		<dc:creator>joabj</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.joabj.com/blog/?p=1132</guid>
		<description><![CDATA[For JavaScript programming langauge, the Web page is a single object, called the document object. The Document Object Model (DOM), therefore, is the way Web programmers can read and update elements on a page using JavaScript. To step back for a moment, JavaScript works with browsers though object models. The Window is the global object [...]]]></description>
			<content:encoded><![CDATA[<p>For JavaScript programming langauge, the Web page is a single object, called the <strong>document</strong> object. The Document Object Model (DOM), therefore, is the way Web programmers can read and update elements on a page using JavaScript.</p>
<p>To step back for a moment, JavaScript works with browsers though object models. The Window is the global object model for the language, for browser operations. All variables assigned at the Window level are global properties.,i.e. Window.counter = 97. In essence, this means that the variable &#8220;counter&#8221; can be accessed from anywhere in the window.</p>
<p>The Document Object Model (DOM) is a property of the Window object, and it is the one that JavaScript programmers work with most often. The DOM contains the properties that determine how the web page is displayed by the browser. This provides the basis for JavaScript to modify the Web page. JavaScript is event driven programming, in which the program waits for an event to happen, in this case some action by the user of the browser.</p>
<p>Commonly used elements, such as images and forms are represented as arrays, i.e. Document.images[3] refers to a specific image, one tagged by the <img *> HTML tag. </p>
<p><i>Material taken from the following books (all mistake are my own)&#8230;.</i></p>
<tr>
<td>
<iframe src="http://rcm.amazon.com/e/cm?t=httpwwwjoabjc-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0596521871&#038;ref=tf_til&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>
</td>
<td>
<iframe src="http://rcm.amazon.com/e/cm?t=httpwwwjoabjc-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0596805527&#038;ref=tf_til&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td>
</td>
<p><!-- Google Ads --></p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-0956514146719150";
/* Blog Ad */
google_ad_slot = "3094432839";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- End Google Ads --></p>
<p><!-- Google Analytics--></p>
<p><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><br />
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3825357-2");
pageTracker._trackPageview();
} catch(err) {}</script><br />
<!--End Google analytics --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joabj.com/blog/?feed=rss2&#038;p=1132</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regex: Encompassing your needs with parentheses</title>
		<link>http://www.joabj.com/blog/?p=902</link>
		<comments>http://www.joabj.com/blog/?p=902#comments</comments>
		<pubDate>Thu, 03 Feb 2011 03:01:13 +0000</pubDate>
		<dc:creator>joabj</dc:creator>
				<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[alternation]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://www.joabj.com/blog/?p=902</guid>
		<description><![CDATA[While Character Classes can be used to sum up the possible variations within a single space, the regular expression language also provides a way to look for multiple multi-character expressions, through the use of parentheses, (), as well as the &#124; symbol. For instance, if you are looking, in a particular location, for either the [...]]]></description>
			<content:encoded><![CDATA[<p>While Character Classes can be used to sum up the possible variations within a single space, the regular expression language also provides a way to look for multiple multi-character expressions, through the use of parentheses, <strong>()</strong>,  as well as the <strong>|</strong> symbol. </p>
<p>For instance, if you are looking, in a particular location, for either the word &#8220;train&#8221; or &#8220;bus&#8221; you would express that as &#8220;(train|bus).&#8221; </p>
<p>Alternation can also be used to alternative word spellings as well. If you are looking for either the word &#8220;color&#8221; or &#8220;colour,&#8221; one way to build the expression would be &#8220;col(o|ou)r.&#8221;</p>
<p><i>Material taken from the book</i>:<br />
<center><br />
<iframe src="http://rcm.amazon.com/e/cm?t=httpwwwjoabjc-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0596528124&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe><br />
</center><br />
<i>all mistakes are my own however&#8230;&#8211;Joab Jackson</i></p>
<p><!-- Google Ads --></p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-0956514146719150";
/* Blog Ad */
google_ad_slot = "3094432839";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- End Google Ads --></p>
<p><!-- Google Analytics--></p>
<p><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><br />
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3825357-2");
pageTracker._trackPageview();
} catch(err) {}</script><br />
<!--End Google analytics --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joabj.com/blog/?feed=rss2&#038;p=902</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regex: character classes bracket the possible</title>
		<link>http://www.joabj.com/blog/?p=887</link>
		<comments>http://www.joabj.com/blog/?p=887#comments</comments>
		<pubDate>Sun, 23 Jan 2011 16:54:46 +0000</pubDate>
		<dc:creator>joabj</dc:creator>
				<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[character classes]]></category>

		<guid isPermaLink="false">http://www.joabj.com/blog/?p=887</guid>
		<description><![CDATA[Explaining how character classes work within regular expressions]]></description>
			<content:encoded><![CDATA[<p>One of the ways in which regular expressions (regex) are more powerful than simple pattern matching filters is that the regex syntax offers a wide set of metacharacters that can be used to identify complex patterns. </p>
<p>For instance, regex uses a set of square brackets, <strong>[]</strong>, to hold a character class, or a range of possible characters that could fit within a single space. </p>
<p>In other words, using a character class, you can match an expression that could have one of a number characters in a given space. </p>
<p>For instance, the regex <strong>h[eu]llo World</strong>, would match either <strong>Hello World</strong> or <strong>Hullo World</strong>. </p>
<p>Character classes have a range of metacharacters to help advanced searching.</p>
<p>Within a character class, the <strong>-</strong> character represents a range of characters: <strong>&lt;H[1-6]></strong> would match <strong>&lt;H1> </strong>through <strong>&lt;H6></strong>.</p>
<p>Ranges within character classes also work for letters, though they are case sensitive: <strong>[a-zA-Z]</strong> would work for all letters. </p>
<p>Character classes can consist of a combination of ranges and literal characters: <strong>[a-z7!]</strong>. </p>
<p>Note, however, that each instance of a character class is a set of possible values <em>for a single space</em>: <strong>[acquainted]</strong> will match every word with the letters, a,c,q,u,a,i,n,t, e or d, not the word acquainted itself. </p>
<p>You can also find phrases that do not have a particular phrase, through the <strong>^</strong> within a character class: <strong>[^c]</strong> matches any word that does not contain the letter c. <strong>s[^k]</strong> will highlight any instances where an &#8220;s&#8221; is not followed by a &#8220;k,&#8221; and ignore those where it is (such as &#8220;sky&#8221;).</p>
<p>The dot, &#8220;.&#8221; is a place holder. It represents any character. For instance, if you are looking for a word with an unknown second character (&#8220;h7llo&#8221; or &#8220;hxllo,&#8221;) you could use <strong>h[.]llo</strong> which would match any occurrence of the pattern &#8220;h?llo&#8221; </p>
<p>Keep in mind that, within regular expressions, regex metacharacters such as &#8220;^&#8221; and &#8220;-&#8221; have different meanings when they are placed inside characters classes than when they are outside them.</p>
<p><i>Material taken from the book</i>:<br />
<center><br />
<iframe src="http://rcm.amazon.com/e/cm?t=httpwwwjoabjc-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0596528124&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe><br />
</center><br />
<i>all mistakes are my own however&#8230;&#8211;Joab Jackson</i></p>
<p><!-- Google Ads --></p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-0956514146719150";
/* Blog Ad */
google_ad_slot = "3094432839";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- End Google Ads --></p>
<p><!-- Google Analytics--></p>
<p><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><br />
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3825357-2");
pageTracker._trackPageview();
} catch(err) {}</script><br />
<!--End Google analytics --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joabj.com/blog/?feed=rss2&#038;p=887</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix: Getting started with vi</title>
		<link>http://www.joabj.com/blog/?p=777</link>
		<comments>http://www.joabj.com/blog/?p=777#comments</comments>
		<pubDate>Sun, 04 Apr 2010 19:31:53 +0000</pubDate>
		<dc:creator>joabj</dc:creator>
				<category><![CDATA[Linux Server Administration]]></category>
		<category><![CDATA[Shell programming]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[editors]]></category>
		<category><![CDATA[vi]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.joabj.com/blog/?p=777</guid>
		<description><![CDATA[How to use the vi test editor in Unix and Linux.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.theregister.co.uk/2003/09/11/bill_joys_greatest_gift/" target-"_blank">Created</a> by Bill Joy in 1976, vi is a text editor for the Unix/Linux command line. At first glance, it may seem crude by today&#8217;s standards for text editors, but it is useful for working in remote command-line sessions.</p>
<p>To open vi at the command line, simple type vi. If you want to open a specific file with vi, type vi and then the filename.</p>
<p>One thing to keep in mind about vi is that it operates in three modes. You must be aware of what mode you are in at any given time, because each reacts differently to what you type in. The three modes:</p>
<p><strong>Command mode</strong> is the default mode. When you first start vi, you are in command mode. You can not enter text. Here you are entering commands. Most keystrokes have a command associated with them.</p>
<p><strong>Input mode</strong> is where you actually enter text. the easiest way to get into input mode from command mode is to type the letter  &#8220;i.&#8221; Then you can start typing. (&#8220;a&#8221; will also work). To get out of insert mode back into command mode, hit the escape key.</p>
<p><strong>Ex mode</strong> is used for file handling duties, as well as performing substitution tasks. It is kicked off by typing a &#8220;:&#8221; from the command mode. </p>
<p>For instance , if you want to save a file, you&#8217;d hit escape type in &#8220;:w [filename]&#8221; If you want to quit, type in &#8220;:q&#8221; If you haven&#8217;t saved your file since making any changes however, it won&#8217;t let you quit, unless you put an &#8220;!&#8221; at the end of the command, &#8220;:q!&#8221;</p>
<p>You can also combine the commands for writing and quitting, i.e. &#8220;:wq&#8221; </p>
<p>vi can be <a href="http://www.linux.com/archive/feed/19661" target="_blank">frustrating</a> to use for beginners; it really is designed to be lightening fast for those who have memorized many of its <a href="http://www.lagmonster.org/docs/vi.html" target="_blank">myriad commands</a>.</p>
<p>While you will have to figure out which commands are worth memorizing for yourself, here are a few that I myself have found handy: </p>
<p><i>(all of these are executed from the command line, unless otherwise noted)</i>:</p>
<p> <strong>)</strong> and <strong>(</strong> : Jump ahead one sentence or jump back one sentence, respectively.</p>
<p><strong>:[Number]</strong>: This will allow you to jump ahead by the number of lines you designate. For instance. &#8220;:4&#8243; will jump the cursor ahead 4 lines. Using a negative number will jump back by the number you designate.</p>
<p><strong>ctrl-f, ctrl-b, and ctrl-u, ctrl-d</strong>: Jump a screen (24 lines) forward, back, up or down, respectively. </p>
<p><strong>o</strong> and <strong>O</strong>: will move from command mode to insert mode, but insert a new blank line. This is also handy for adding a new line at the end of the document.</p>
<p><strong>dd</strong>: delete a line. (Note: This is also the first step of a cut and paste operation. See below).</p>
<p><strong>dw</strong>: delete a word.</p>
<p><strong>p</strong> and <strong>P</strong>: This means to paste, as in cut and paste. When you delete something with dd or dw, it goes into the buffer. This command retrieves what is in the buffer.</p>
<p><strong>yy</strong>: The command allows for copying and pasting, without the cutting of copy. Typing yy copies the line that the cursor is on.</p>
<p><strong>u</strong> undoes the last command (though there seems to be no undo for the edit mode).</p>
<p><strong>/</strong> and <strong>?</strong> are search operators. Type them in and then the text you are searching for. / looks for the next instance after the cursor, ? looks for the first instance before the cursor.</p>
<p><center><br />
<i>Taken from this book:</i><br />
<iframe src="http://rcm.amazon.com/e/cm?t=httpwwwjoabjc-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0072520426&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe><br />
</center><br />
<i>&#8230;as well as a class I&#8217;m taking on Unix. All mistakes are my own, however.&#8211;Joab Jackson</i></p>
<p><!-- Google Ads --></p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-0956514146719150";
/* Blog Ad */
google_ad_slot = "3094432839";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- End Google Ads --></p>
<p><!-- Google Analytics--></p>
<p><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><br />
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3825357-2");
pageTracker._trackPageview();
} catch(err) {}</script><br />
<!--End Google analytics --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joabj.com/blog/?feed=rss2&#038;p=777</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix : Redirection basics, part 1</title>
		<link>http://www.joabj.com/blog/?p=760</link>
		<comments>http://www.joabj.com/blog/?p=760#comments</comments>
		<pubDate>Sat, 03 Apr 2010 20:11:15 +0000</pubDate>
		<dc:creator>joabj</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Linux Server Administration]]></category>
		<category><![CDATA[process management]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[redirection]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://www.joabj.com/blog/?p=760</guid>
		<description><![CDATA[How redirection works in Unix and Linux]]></description>
			<content:encoded><![CDATA[<p><em>Note: This entry does not discuss Unix pipes. That will be part 2.<br />
</em></p>
<p>One of the powers of the Unix command line is the ability to <a href="http://www.linfo.org/redirection.html" target="_blank">redirect</a> input and output of either end of the command (for most commands, anyway).</p>
<p>By default, Unix assumes that the default input will come from the keyboard, and the default output would go to the display. So, to view all the files in a directory, you type &#8220;ls&#8221; at the command line and the program returns to the display of all the files in a directory. </p>
<p>But you can also direct the output of a program to another source, such as to a text file. You can also specify a new source of input.</p>
<p>This is done using the &#8220;>&#8221; and the &#8220;&lt;&#8221; characters. </p>
<p>For instance, say you want to get a list of files in a directory, but instead of having them appear on the screen, you want to put them in a new file, called ListOfInfo.txt. then you&#8217;d type:</p>
<blockquote><p>
$ls > ListOfInfo.txt
</p></blockquote>
<p>And if you wanted to add more information to this file, you could append the info with &#8220;>>&#8221;, i.e.:</p>
<blockquote><p>
$ps -aux>> ListOfInfo.txt
</p></blockquote>
<p>(Otherwise, with just a single &#8220;>&#8221; Unix will just overwrite the contents of an existing file). </p>
<p>Just as &#8220;>&#8221; directs the output, using &#8220;&lt;&#8221; will direct input. For instance&#8230;</p>
<blockquote><p>
$wc &lt; ListOfInfo.txt
</p></blockquote>
<p>&#8230;will give you the word count of the ListOfInfo.txt file. </p>
<p>You can mix and match these commands. For instance&#8230;</p>
<blockquote><p>
$wc &lt; ListOfInfo.txt > WCResults.txt
</p></blockquote>
<p>Keep in mind that not all Unix programs accept redirection, of either input or output. A command such as &#8220;mkdir&#8221; can&#8217;t accept input or redirect its work elsewhere.</p>
<p><center>* * *</center></p>
<p>When running a shell, Unix keeps three different <a href="http://en.wikipedia.org/wiki/Standard_streams" target="_blank">streams</a>, or files, for input/output purposes. Each gets a file descriptor number (More on that later). They are:</p>
<p><strong>Standard Input</strong>: The file that captures the input, usually from the keyboard (file descriptor # <strong>0</strong>).</p>
<p><strong>Standard Output</strong>: The file that captures the output, which is usually sen to the terminal display (It has a File descriptor # <strong>1</strong>).</p>
<p><strong>Standard Error</strong>: This file captures the error messages from the shell or the running program (It has a file descriptor # <strong>2</strong>). </p>
<p>With this in mind, &#8220;>&#8221; really means &#8220;1>&#8221; and &#8220;&lt;&#8221; is shorthand for &#8220;0&lt;&#8221;. </p>
<p>All this means you can redirect standard input output and error messages. For instance, say you want to capture an error message in a text file. You can&#8217;t do that with the standard redirect. A wc on a nonexistent file reirected to an output file will not send the error message to the file. Instead, you can type:</p>
<blockquote><p>
$wc phonyfile.txt 2> ErrorFile.txt
</p></blockquote>
<p>Note, you can also group these redirections for a single stream. &#8220;1>$2&#8243; sends standard output to the standard error file, and &#8220;2>$1&#8243; sends the error output to the standard output. </p>
<p><center><br />
<i>Taken from this book:</i><br />
<iframe src="http://rcm.amazon.com/e/cm?t=httpwwwjoabjc-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0072520426&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe><br />
</center><br />
<i>&#8230;as well as a class I&#8217;m taking on Unix. All mistakes are my own, however.&#8211;Joab Jackson</i></p>
<p><!-- Google Ads --></p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-0956514146719150";
/* Blog Ad */
google_ad_slot = "3094432839";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- End Google Ads --></p>
<p><!-- Google Analytics--></p>
<p><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><br />
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3825357-2");
pageTracker._trackPageview();
} catch(err) {}</script><br />
<!--End Google analytics --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joabj.com/blog/?feed=rss2&#038;p=760</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix: Converting files between DOS and Unix</title>
		<link>http://www.joabj.com/blog/?p=746</link>
		<comments>http://www.joabj.com/blog/?p=746#comments</comments>
		<pubDate>Mon, 01 Mar 2010 02:41:31 +0000</pubDate>
		<dc:creator>joabj</dc:creator>
				<category><![CDATA[command line]]></category>
		<category><![CDATA[datatypes]]></category>
		<category><![CDATA[File Systems]]></category>
		<category><![CDATA[Linux Server Administration]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[File Conversion]]></category>

		<guid isPermaLink="false">http://www.joabj.com/blog/?p=746</guid>
		<description><![CDATA[The difference between Unix and DOS text files.]]></description>
			<content:encoded><![CDATA[<p>Recently I found that, after a uploading file from a Windows computer to a Linux one, and opened the file from the command line, Ubuntu would notify me that it was converting it from the DOS format. </p>
<p>Even if it was a standard text file (.txt) filled with ASCII characters, it still needed converting. </p>
<p>Why? Aren&#8217;t text files the same across different operating systems? Evidently not.</p>
<p>Unix handles end-of-line signifiers differently than Windows/DOS does, according to Sumitabha Das&#8217;s book <i>&#8220;Your Unix&#8221;</i>. </p>
<p>Specifically, DOS uses two different sets of characters, &#8220;\r&#8221; (for Carriage Return [CR], or simply &#8220;enter&#8221;) and &#8220;\n&#8221; (for Line Feed [<a href="http://msdn.microsoft.com/en-us/library/cc239249%28PROT.10%29.aspx">LF</a>]) to signify the end of a line. </p>
<p>Unix only uses one, namely LF</p>
<p>These markers can both be seen by examining text files with <a href="http://">Octal Dump</a>.</p>
<p>Ubuntu anyway seems to handle DOS text files easily in day to day operation. Nonetheless, most variants of Unix/Linux have a set of utilities to convert files from Windows/DOS into Unix, and back again. They are called <a href="http://linuxcommand.org/man_pages/dos2unix1.html">dos2unix</a> and <a href="http://linux.die.net/man/1/unix2dos">unix2dos</a>, respectively. </p>
<p><center><br />
<i>Taken from this book:</i><br />
<iframe src="http://rcm.amazon.com/e/cm?t=httpwwwjoabjc-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0072520426&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe><br />
</center><br />
<i>&#8230;as well as a class I&#8217;m taking on Unix. All mistakes are my own, however.&#8211;Joab Jackson</i></p>
<p><!-- Google Ads --></p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-0956514146719150";
/* Blog Ad */
google_ad_slot = "3094432839";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- End Google Ads --></p>
<p><!-- Google Analytics--></p>
<p><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><br />
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3825357-2");
pageTracker._trackPageview();
} catch(err) {}</script><br />
<!--End Google analytics --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joabj.com/blog/?feed=rss2&#038;p=746</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix: Decoding binary files with Octal Dump</title>
		<link>http://www.joabj.com/blog/?p=735</link>
		<comments>http://www.joabj.com/blog/?p=735#comments</comments>
		<pubDate>Mon, 22 Feb 2010 13:50:37 +0000</pubDate>
		<dc:creator>joabj</dc:creator>
				<category><![CDATA[Linux Server Administration]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[binary]]></category>
		<category><![CDATA[forensics]]></category>
		<category><![CDATA[od]]></category>

		<guid isPermaLink="false">http://www.joabj.com/blog/?p=735</guid>
		<description><![CDATA[Decoding binary program's with the Unix octal dump (od) command.]]></description>
			<content:encoded><![CDATA[<p>In many cases with Unix/Linux, if you want to view a file, using the <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?cat">cat</a> command works just fine. The phrase &#8220;cat samplescript.txt&#8221;, will reveal, at the command line, the content of that file.</p>
<p>Cat won&#8217;t work for <a href="http://www.gigamonkeys.com/book/practical-parsing-binary-files.html">binary files</a>, because binary files contain non-printing characters (Or non-ASCII characters). Run a cat on a binary program, such as sed, will only get you a screen full of gibberish, and may even destroy the terminal session itself.</p>
<p>(Storing programs as binary files is <a href="http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/BitOp/asciiBin.html">more efficient</a> than storing them in <a href="http://www.asciitable.com/">ASCII</a>, largely because binary programs use all eight bits in a byte [up to 256 possible combinations], whereas ASCII only uses seven [128 combinations] leaving the last bit to sign the byte).</p>
<p>What <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?od">Octal Dump</a> (od from the command line) does is display the contents of a binary file, including an execution files, as sets of <a href="http://en.wikipedia.org/wiki/Octal">octals</a>. </p>
<p>As the name suggests, the octal numbering system is a numbering system in base eight. When used with the &#8220;-bc&#8221; option, he od program <a href="http://en.wikipedia.org/wiki/Octal#Octal_to_Binary_Conversion">renders</a> each byte of the program in octal.</p>
<p>For instance, rendering this command from the command line in the /bin directory of binary files:</p>
<blockquote><p>od -bc sed</p></blockquote>
<p>will return a row of six digit octals, preceded by a seven digit number that is the offset, or position, of the first byte in the line. Below each octal is a its conversion into ASCI characters, if the resulting decimal conversion falls between decimal 33 and 127.</p>
<p>As an aside, to convert from octal to decimal yourself, simply multiply each digit of the octal number by a successive power of eight, going from right to left. So, if the octal is 114, then you would calculate (<strong>1</strong>* [8^2] + <strong>1</strong> * [8^1] + <strong>4</strong> * [8 ^ 0]), which would equal (64 + 8 + 4), which would equal 76 </p>
<p><center><br />
<i>Taken from this book:</i><br />
<iframe src="http://rcm.amazon.com/e/cm?t=httpwwwjoabjc-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0072520426&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe><br />
</center><br />
<i>&#8230;as well as a class I&#8217;m taking on Unix. All mistakes are my own, however.&#8211;Joab Jackson</i></p>
<p><!-- Google Ads --></p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-0956514146719150";
/* Blog Ad */
google_ad_slot = "3094432839";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- End Google Ads --></p>
<p><!-- Google Analytics--></p>
<p><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><br />
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3825357-2");
pageTracker._trackPageview();
} catch(err) {}</script><br />
<!--End Google analytics --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joabj.com/blog/?feed=rss2&#038;p=735</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix: Indexing files with inode</title>
		<link>http://www.joabj.com/blog/?p=732</link>
		<comments>http://www.joabj.com/blog/?p=732#comments</comments>
		<pubDate>Wed, 17 Feb 2010 04:17:50 +0000</pubDate>
		<dc:creator>joabj</dc:creator>
				<category><![CDATA[File Systems]]></category>
		<category><![CDATA[Linux Server Administration]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://www.joabj.com/blog/?p=732</guid>
		<description><![CDATA[How Unix uses inodes to index all the files on a system.]]></description>
			<content:encoded><![CDATA[<p>In Unix, an inode is a data structure that holds information about a file, or set of data blocks. You can think of it as an index, or a collection of metadata about a file. It contains info such as the owner, the permissions, the date created and last modified, as well as the location of the data blocks that contain the information.It is kept on a disk in a separate location from the data blocks themselves.</p>
<p>&#8220;When users search for or access a file, the UNIX system searches through the inode table for the correct inode number. When the inode number is found, the command in question can access the inode and make the appropriate changes if applicable,&#8221; according to the <a href="http://www.ibm.com/developerworks/aix/library/au-speakingunix14/index.html">online paper</a> about inodes posted by IBM.</p>
<p>Each time a user creates a file, a corresponding inode is created. It is possible to run out of inode numbers. Typically, however, a disk will run out of space first before it runs out of inode numbers, according to one <a href="http://www.linfo.org/inode.html" target="_blank">instructional site</a>. Although typically, the number of inodes is set by the operating system, they can be set during the set up process of the file system.</p>
<p>By using numerical inode numbers as identifiers, the OS can have multiple file names, in different directories, point to the same file (Called hard linking). inodes are also handy during file system maintenance or recovery operations, such as fsck. fsck <a href="http://adminschoice.com/repairing-unix-file-system-fsck" target="_blank">checks</a> for lost inodes, or inodes with no pointers, and attempts to repair them.</p>
<p>One can use the &#8220;df&#8221; command to check the remaining percentage of inodes left on a system. For Ubuntu Linux, the command is &#8220;df -i.&#8221; To find the inode numbers of all the files in a directory, type &#8220;ls -i&#8221;</p>
<p><i>&#8211;Joab Jackson</i></p>
<p><!-- Google Ads --></p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-0956514146719150";
/* Blog Ad */
google_ad_slot = "3094432839";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- End Google Ads --></p>
<p><!-- Google Analytics--></p>
<p><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><br />
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3825357-2");
pageTracker._trackPageview();
} catch(err) {}</script><br />
<!--End Google analytics --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joabj.com/blog/?feed=rss2&#038;p=732</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows: Troubleshooting a non-working Hosts file</title>
		<link>http://www.joabj.com/blog/?p=724</link>
		<comments>http://www.joabj.com/blog/?p=724#comments</comments>
		<pubDate>Sat, 30 Jan 2010 20:10:34 +0000</pubDate>
		<dc:creator>joabj</dc:creator>
				<category><![CDATA[DNS]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.joabj.com/blog/?p=724</guid>
		<description><![CDATA[What to do when Windows XP doesn't resolve to your hosts file.]]></description>
			<content:encoded><![CDATA[<p>What do you do when your Windows XP computer isn&#8217;t recognizing the Hosts file? Here are a few possible solutions.</p>
<p>Recently, I ran into this devil of a problem. I wanted to do some internal testing of a Web site, from a browser on a Windows XP machine. So I added an entry in the <a href="http://vlaurie.com/computers2/Articles/hosts.htm" target="_blank">hosts</a> file on the XP machine that would redirect joabj.com to the internal IP address of the server (&#8220;192.168.0.33 joabj.com&#8221; in this case). (Typically, in WinXP, the Hosts file was located in the C:\WINDOWS\system32\drivers\etc folder). Yet, the browser still returned errors!</p>
<p>Yet, the browser kept consulting the external DNS service first, and returning the wrong page (my cable modem page in this case). </p>
<p>Most infuriatingly, Windows host file command line tools (namely, ping and SSH) recognized entries, but the browser did not!! If I ping&#8217;ed my domain name entered into the Hosts file (&#8220;ping -a joabj.com&#8221; in this case), it pinged the correct IP number (&#8220;reply from 192.168.0.33:&#8221; etc&#8230;).</p>
<p>Surfing the Web, I came across a number of different solutions to this problem:</p>
<p>*<b>Reboot</b>: Not only rebooting the machine (duh!), but emptying the browser caches, flushing the DNS (from the command line, type &#8220;ipconfig /flushdns&#8221;). </p>
<p>*<b>Extra empty characters in the Hosts file</b>: Evidently, Windows doesn&#8217;t like an empty space behind the entry, i.e. &#8220;192.168.0.33 joabj.com &#8221; rather than &#8220;192.168.0.33 joabj.com&#8221; &#8211;make sure you don&#8217;t add in an empty space.</p>
<p>*<b>Corrupt Hosts file</b>: This could be the case even if it opens in Notepad o.k. Try replacing the existing Hosts file with a new one. </p>
<p>*<b>Specify exact subdomain in Hosts file</b>: This is the solution that ultimately worked for me, after trying all these other more complicated solutions, described below. </p>
<p>In a nutshell, if you plan on using the address &#8220;www.YOURDOMAIN.com&#8221; you should type &#8220;www.YOURDOMAIN.com&#8221; into the Hosts file, rather than just &#8220;YOURDOMAIN.com&#8221;. </p>
<p>So, for me, once I replaced  &#8220;192.168.0.33 joabj.com&#8221; with &#8220;192.168.0.33 www.joabj.com&#8221; then using http://www.joabj.com worked fine, whereas before it wouldn&#8217;t.</p>
<p>*<b>Editor adding extension to Hosts file name</b>: Sometimes a text editor could add on the .txt to the file name during save, making it Hosts.txt rather than just Hosts. Of course, then Windows won&#8217;t recognize the Hosts file, and Explorer won&#8217;t show, by default, the suffixes of file names. </p>
<p>If perusing from Explorer, set the folder view options to show suffixes. From Explorer, go Tools&#8211;>Folder Options&#8211;>View and uncheck &#8220;Hide extensions for known folder types.&#8221; If Hosts is a .txt, remove the .txt from the file name.</p>
<p>*<b>XP&#8217;s DNS Cache service taking priority</b>: One <a href="http://accs-net.com/hosts/faq.html#19" target="_blank">troubleshooting site</a> suggested this as a probable cause. It didn&#8217;t make any difference in my case. </p>
<p>To disable this service, go Start&#8211;>Control Panel&#8211;>Administrative Tools&#8211;>Component Services&#8211;>Services(Local). Then search for DNS Cache and disable it. You could just stop the service to check if it has any affect, though it will start up again on reboot. The Manual setting just means that the service will start up, once a browser is fired up. The Disable option turns it off altogether, until you turn it back on again.</p>
<p>According to other people who&#8217;ve <a href="http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/XP/Q_21675563.html" target="_blank">tried</a> this, disabling DNS Cache should have no ill-effect on your DNSing. </p>
<p>*<b>Reorder the DNS lookup sequence</b>: Typically, Windows XP will consult the local Hosts file before checking with a DNS server to resolve domain name. But, sometimes not. </p>
<p>You change the order of the lookup in the registry. (STANDARD DISCLAIMER: DO not mess w/ registry until you know what you are doing). </p>
<p>To fire up the registry editor, do Start&#8211;>Run and put &#8220;regedit&#8221; in the box. </p>
<p>Once in regedit, go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\ServiceProvider . Once there, you will see a number of entries, including &#8220;DnsPriority&#8221; &#8220;HostsPriority&#8221; &#8220;LocalPriority&#8221; and &#8220;NetbtPriority&#8221; &#8211;which are the entries for DNS-based lookup, Hosts file-based lookup, Computer-based lookup and NetBios-based look-up. (More info on that <a href="http://www.bleepingcomputer.com/tutorials/tutorial52.html">here</a>).</p>
<p>In the data column for each you see a number in parenthesis. This number is the priority for that lookup. The lower the number, the earlier in the domain name resolution sequence it is consulted (evidently the range is between -32768 and 32767). If the DNS number is lower than the Hosts&#8217; number, then you want to give the Hosts number a lower number than the DNS number. </p>
<p>So if DnsPriority is 5000 and Hosts is 7000, you may want to change Hosts to, say, 4500</p>
<p>Keep in mind, that when you set the number, by right clicking on the entry and choosing &#8220;modify,&#8221; you just can&#8217;t add the number as is &#8212; you will have to enter the new number in either hexidecimal or binary.</p>
<p>One easy way to convert a number into hexadecimal is to call up Windows calculator, switch the view from standard to scientific, then enter the number into the field for entering a number. After the number is entered, look for where &#8220;dec&#8221; is selected on top of the calculator, and switch that to &#8220;hex.&#8221;</p>
<p>&#8211;Joab Jackson<br />
<!-- Google Ads --></p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-0956514146719150";
/* Blog Ad */
google_ad_slot = "3094432839";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
<!-- End Google Ads --></p>
<p><!-- Google Analytics--></p>
<p><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script><br />
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-3825357-2");
pageTracker._trackPageview();
} catch(err) {}</script><br />
<!--End Google analytics --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.joabj.com/blog/?feed=rss2&#038;p=724</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
