<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss1full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns="http://purl.org/rss/1.0/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<channel rdf:about="http://aplawrence.com//rss/fullMacOSX.rdf">
<title>MacOSX Site News at A.P.Lawrence.com</title>
<link>http://aplawrence.com/</link>
<description>
MacOSX feed at aplawrence.com: Thousands of articles, reviews, consultants listings, skills tests, opinion, how-to's for Unix, Linux and Mac OS X, networking, web site maintenance and more.. 
</description>
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>6</sy:updateFrequency>
<sy:updateBase>2008-01-01T00:00+00:00</sy:updateBase>
<dc:language>en</dc:language>
<dc:publisher>A.P. Lawrence</dc:publisher>
<dc:rights>Copyright  A.P. Lawrence</dc:rights>
<dc:creator>A.P. Lawrence (mailto:rssfeeds@aplawrence.com)</dc:creator>
<dc:date>2014-11-14T05:05:10+00:00</dc:date>
<image rdf:resource="http://aplawrence.com/image21.gif">
</image>
<items>
<rdf:Seq>
<rdf:li rdf:resource="http://aplawrence.com/Basics/restrict_script_to_console.html" />
<rdf:li rdf:resource="http://aplawrence.com/MacOSX/time_machine_hang.html" />
<rdf:li rdf:resource="http://aplawrence.com/Unixart/seven-layer-osi-cake.html" />
<rdf:li rdf:resource="http://aplawrence.com/Unixart/system_admin.html" />
<rdf:li rdf:resource="http://aplawrence.com/Basics/trapping_errors.html" />
<rdf:li rdf:resource="http://aplawrence.com/Basics/ps_and_grep.html" />
<rdf:li rdf:resource="http://aplawrence.com/Basics/tput_stty.html" />
<rdf:li rdf:resource="http://aplawrence.com/Basics/basic_firewall.html" />
</rdf:Seq>
</items>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rdf+xml" href="http://feeds.feedburner.com/aplawrence/DrTi" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="aplawrence/drti" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>41.889582</geo:lat><geo:long>-70.894066</geo:long></channel>
<image rdf:about="http://aplawrence.com/image21.gif">
<title>A.P.Lawrence Logo</title>
<url>http://aplawrence.com/image21.gif</url>
<link>http://aplawrence.com</link>
</image>


<item rdf:about="http://aplawrence.com/Basics/restrict_script_to_console.html">
<title>Restrict script to console use  </title>
<description>Linux,Linux,MacOSX,MacOSX,Scripting,Shell,Unix 

2013/11/05&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;p&gt;A customer asked for a way to prevent a certain shell script from execution by SSH - it apparently it is supposed to be run only at the console.&lt;/p&gt;
&lt;p&gt;One choice is to examine 'tty'. Something like this, perhaps:&lt;/p&gt;
&lt;pre&gt;
&lt;br /&gt;
#!/bin/bash
case `tty` in 
/dev/tty*) echo "ok";;
/dev/pts/*) echo "No";exit 0;
esac
echo "Will proceed"
&lt;br /&gt;
&lt;br /&gt;
&lt;/pre&gt;
&lt;p&gt;Or perhaps one of the SSH variables can be tested:&lt;/p&gt;

&lt;pre&gt;
&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash
test -n $SSH_CLIENT &amp;amp;&amp;amp; exit 1
echo "Will proceed"
&lt;br /&gt;
&lt;/pre&gt;
&lt;p&gt;However, that $SSH_CLIENT will not be set if you "su -" to another user after logging in with ssh, so you may need to use the more direct test.&lt;/p&gt;


&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Basics/restrict_script_to_console.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Want to showcase your product to our audience? Check our &lt;a href="http://aplawrence.com/advert.html"&gt;advertising options.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://samepage.io?partner=683d6fe8b2973c7cc2a4ba099fd949be56d864fe"&gt;Samepage - Redefining how people create and share information&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server, Firewall and more&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/aplawrence/DrTi?a=HTWxaxuBuK4:1R2sguRRb5Q:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/aplawrence/DrTi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
<link>http://aplawrence.com/Basics/restrict_script_to_console.html</link>
</item>
<item rdf:about="http://aplawrence.com/MacOSX/time_machine_hang.html">
<title>Time Machine Startup Beach Ball Hang  </title>
<description>MacOSX 

2013/10/06&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;!-- PLACEAD --&gt;&lt;!-- BIG LEFT --&gt;

&lt;p&gt;I had a problem with Time Machine Backups hanging up my machine at the beginning of a backup.  The hang was not long; I'd just get spinning beach balls while the backup disk spun up. After that, I'd have normal operations again until the next time that disk was called for backup.&lt;/p&gt;

&lt;p&gt;I use two Time Machine disks - Time Machine switches between them automatically, first using one and then the other.  Only one of the disks caused the beach ball hang.&lt;/p&gt;

&lt;p&gt;Plainly there is something different about this disk.  It's a sleepy head, it doesn't like waking up. Plainly there is something wrong with Time Machine also as it shouldn't usurp other CPU scheduling so aggressively.&lt;/p&gt;

&lt;p&gt;I Googled around a bit and found a bunch of things that sound to me like OPPs (Other People's Problems) so I did a little experimentation on my own.  I found something interesting and useful.&lt;/p&gt;

&lt;p&gt;Here's what I found.  If I run this script in background, I do not experience any hangs when Time Machine wants to use that disk:&lt;/p&gt;

&lt;pre&gt;
while :
do
for i in /Volumes/TM2
do
touch "$i/uppity"
ls -l  "$i/uppity"
done
sleep 300
done
&lt;/pre&gt;

&lt;p&gt;Obviously all that is doing is keeping that particular disk from going to sleep.  I used the "for i in /Volumes/TM2" loop so that I can add other disks if need be.   With that running, I have no more regular interruptions of my other work.&lt;/p&gt;

&lt;p&gt;That this works surprised me.  I expected that I'd see a hang on initial use, but I do not.  That says this is not a general flaw caused by not enough interrupts in the disk driver.  It's a more specific flaw of not enough interrupts under some specific conditions.  Apparently Time Machine causes those conditions.&lt;/p&gt;

&lt;p&gt;Here are some of the links I found concerning OPPs.&lt;/p&gt;
&lt;ul&gt;

&lt;li&gt;&lt;a href="http://reviews.cnet.com/8301-13727_7-20116246-263/tackling-time-machine-slowdowns-in-os-x/"&gt;Tackling Time Machine slowdowns in OS X&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://alandix.com/blog/2010/07/09/time-machine-when-it-goes-wrong-and-how-to-fix-it/"&gt;Time Machine -  when it goes wrong and how to fix it&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://forums.macrumors.com/showthread.php?t=379066"&gt;time machine slow initial backup fix&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;






&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/MacOSX/time_machine_hang.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Want to showcase your product to our audience? Check our &lt;a href="http://aplawrence.com/advert.html"&gt;advertising options.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://samepage.io?partner=683d6fe8b2973c7cc2a4ba099fd949be56d864fe"&gt;Samepage - Redefining how people create and share information&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server, Firewall and more&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/aplawrence/DrTi?a=s7bEdtDwi7w:sR3Lk2Cml9U:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/aplawrence/DrTi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
<link>http://aplawrence.com/MacOSX/time_machine_hang.html</link>
</item>
<item rdf:about="http://aplawrence.com/Unixart/seven-layer-osi-cake.html">
<title>The Seven Layer inedible OSI cake  </title>
<description>Lighter,Linux,MacOSX,Microsoft,TCP-IP 

2013/08/23&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;!-- PLACEAD --&gt;&lt;!-- BIG LEFT --&gt;
&lt;br /&gt;
&lt;br /&gt;


&lt;p&gt;I have always disliked the OSI model.  No offense to the folks at ISO (though using a jumble of your own acronym is, well, conceited), but I have my reasons.&lt;/p&gt;
&lt;p&gt;The first is that the damn thing is hellishly difficult to memorize.  I was given the mnemonic "A priest saw ten nuns doing pushups".   That's not very helpful.  There are &lt;a href="http://compnetworking.about.com/b/2004/12/06/osi-model-seven-layer-mnemomics-for-networking-students.htm"&gt;other mnemonics&lt;/a&gt;, but none of them are useful in any sense whatsoever,&lt;/p&gt;
&lt;p&gt;Yesterday (or perhaps earlier; time is nebulous in my world), a customer asked my why a vendor from whom he was attempting to buy a new switch was blubbering on about "Layer 2" as though that were important. &lt;/p&gt;
&lt;p&gt;  I became angry.  My feeling is that customers should send checks and keep their yaps shut, especially when it comes to questions like this.  Call me up and ask "How's the weather up there?" and I can, with some effort, answer pleasantly, but seriously: how is anyone expected to politely respond to questions about the OSI model?&lt;/p&gt;
&lt;p&gt;My wife, another hellishly demanding person, disagrees.  She expects me to respond to such bleating on the theory that this will keep checks arriving in our mailbox.  To keep marital harmony, I agreed to write up an explanation for my customer and I gratuitously offer it to you, complete stranger though you may be.&lt;/p&gt;
&lt;h3&gt;One: Physical Layer&lt;/h3&gt;
&lt;p&gt;This is another reason I detest OSI.  This layer defines the electrical and physical aspects of the data connection.  They toss that off lightly as though that were nothing at all, but in fact, unspeakable acts of cruelty happen right here.&lt;/p&gt;
&lt;p&gt;Here, at the physical layer, innocent new born packets are shoved out into a highway jammed with other packets.  Are these packets traveling in an orderly fashion, politely making way for the new born?  Not on ethernet they are not.  Screaming along at reckless speeds that can exceed billions of bits per second, 
new packets can be overrun by their feckless cousins and the resulting carnage is truly awful.  NO PACKET EVER SURVIVES A COLLISION LIKE THAT!&lt;/p&gt;
&lt;h3&gt;Two: Data Link Layer&lt;/h3&gt;
&lt;p&gt;Another disgusting layer only made necessary by the callous disregard of the Physical Layer.  Among other things, this layer has the responsibility of watching the carnage caused by injecting packets blindly as we learned above.&lt;/p&gt;
&lt;p&gt;This is, in fact the Layer 2 my customer asked about.  It is ugly.  That's all you need to know.&lt;/p&gt;
&lt;p&gt;Sigh.  My wife says that my customer may need to know more.  Very well: the salesman mentioned Layer 2 because somebody taught him that was a good way to make you think that you might need another layer and that other layer is more 
expensive, thereby making bigger checks flow to HIS mailbox.&lt;/p&gt;
&lt;p&gt;We talked about this.  For your needs, Layer 2 is enough.  Please leave it at that; I'm tired and have five more layers to explain.&lt;/p&gt;
&lt;h3&gt;Three: Network Layer&lt;/h3&gt;
&lt;p&gt;This is the bully of the OSI model.  Here we have a happy little packet, all shiny and bouncy, zipping along bothering nobody (unless the stupid physical layer throws a new born in front of it).  It runs into the network layer and its life can suddenly be changed forever.  This layer can say "Hey, you! Over here! Let me have a look at your papers, mister.  Aha, just as I thought: you are going to China!".  And then, with no sympathy what so ever, this young packet, usually barely out of childhood, can be thrown out to the Internet where it has to associate with really unsavory characters.  It's barbaric and heartless and yet another reason I hate OSI.&lt;/p&gt;
&lt;h3&gt;Four: Transport Layer&lt;/h3&gt;
&lt;p&gt;Nobody likes the transport layer.  As we have learned, the physical layer is a horribly uncaring parent. Dead packets are nothing to it, but higher layers do care about these poor things and the miracle of Engineering allows the 
transport layer to request the recreation of damaged packets.&lt;/p&gt;
&lt;p&gt;The physical layer often objects to this duplication of effort and will audibly snarl, but really: whose fault is it?  Yes, we are looking at you, physical layer.&lt;/p&gt;
&lt;h3&gt;Five: Session Layer&lt;/h3&gt;
&lt;p&gt;This is often described as the "connection" between computers as though two machines had reached out and are holding hands, smiling at each other.  The music fades and we move to a long shot of two computers living happily ever after.&lt;/p&gt;
&lt;p&gt;Nothing could be farther from the truth.  Computers have been taught to distrust  each other and will reject attempted connections most of the time.  Nowadays, most computers and firewalls are utterly rude about it: it would be like asking someone to dance and having them ignore you as though you were invisible and inaudible.  Why does the OSI model allow such insensitivity?  They hate love, apparently.&lt;/p&gt;
&lt;h3&gt;Six: Presentation Layer&lt;/h3&gt;
&lt;p&gt;Doesn't that put a pretty picture in your mind?  Perhaps you imagined a packet arriving at this layer and being immediately surrounded by attentive servants who pick out new clothes, fix the packets hair and apply makeup before it goes on to the the final stop.  In fact, this layer is more like forced re-education camps, where packets may be stripped of their original structure and repacked so that even their own mother wouldn't know them.  Why does this happen?  It's because the sending computer may be EBCDIC and the recipient may be ASCII.  Too lazy to learn each other's ways, these computers let the presentation layer do the dirty work.&lt;/p&gt;
&lt;p&gt;More and more packets are also asked to disguise themselves - this is called "encryption" which comes from a Greek word that supposedly means "hidden".  Utter nonsense: these packets aren't hidden, they are jumbled and obfuscated and it is the presentation layers job to figure out what they really should be.  This is not easy work, which is why the presentation layer is often in a bad mood.&lt;/p&gt;&lt;h3&gt;Seven: Application layer&lt;/h3&gt;
&lt;p&gt;This is where the poor packet, having survived the high speeds of the wires, having been shoved here and there, torn apart and reconstituted who knows how many times, finally reaches its destination.&lt;/p&gt;
&lt;p&gt;What happens then? Is there a ticker tape parade and heartfelt thanks from 
the computer it has reached?  No, my friends, there is not.  The poor packet is immediately gutted, stripped of its protective layers and tossed into the hungry maw of whatever application (mail, a webserver, whatever) it belongs to.&lt;/p&gt;
&lt;p&gt;That's it.  It dies there, unloved and unremembered.  I cannot abide the brutality of the OSI model!&lt;/p&gt;
&lt;h3&gt;Gory details&lt;/h3&gt;
&lt;p&gt;It is said that there is no honor among thieves and it is also true that there is no love lost between OSI layers.  As has been intimated above, these layers cooperate, but only grudgingly.  For example, when something is not understood  at the transport layer, a RST packet is sent.&lt;/p&gt;
&lt;p&gt;Nobody likes a RST packet.  This is the OSI equivalent of your dinner companion spitting food into a napkin and then handing it to you.  It's beyond rude; it is unconscionable.  &lt;/p&gt;
&lt;p&gt;There are lighter moments.  An "URG" package can be sent.  This is very much like marking a package "Handle with Care" in that it is a cause for great amusement by everything that sees it.  "Oh, you are urgent, are yea? Here, I know a shortcut", and the gullible packet is sent down the wrong way where it will become lost and confused and may never find its way home.&lt;/p&gt;
&lt;h3&gt;The future&lt;/h3&gt;
&lt;p&gt;In recent years, we have seen the development of super-conductivity.  While this technology has not yet reached the masses, rumors are that elements of the OSI model (specifically the "bully" layer explained above) plan to route packets into circular super-conductors where the poor things will loop endlessly.  This is an example of the fiendish sadism yet to come.&lt;/p&gt;
&lt;p&gt;In closing, I hope that you will join me in fighting against the OSI model.  I believe that we could develop a kinder, more gentle model if enough of us raised our voices in protest.&lt;/p&gt;
&lt;p&gt;Will you join me?&lt;/p&gt;


&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Unixart/seven-layer-osi-cake.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Want to showcase your product to our audience? Check our &lt;a href="http://aplawrence.com/advert.html"&gt;advertising options.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://samepage.io?partner=683d6fe8b2973c7cc2a4ba099fd949be56d864fe"&gt;Samepage - Redefining how people create and share information&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server, Firewall and more&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/aplawrence/DrTi?a=5b_UHyse2nQ:LAGV9UDdC8Q:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/aplawrence/DrTi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
<link>http://aplawrence.com/Unixart/seven-layer-osi-cake.html</link>
</item>
<item rdf:about="http://aplawrence.com/Unixart/system_admin.html">
<title>Let's be serious about System Administration  </title>
<description>Employment,Linux,MacOSX,Microsoft 

2013/08/22&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;!-- PLACEAD --&gt;&lt;!-- BIG LEFT --&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;p&gt;Two days ago I wrote a bit of satire that pretended to be a &lt;a href="http://aplawrence.com/Lighter/sysadm_wanted.html"&gt;job posting for a System Administrator job&lt;/a&gt;.  It got mentioned on Reddit and that sent us a lot of traffic and a few comments, though &lt;a href="http://www.reddit.com/r/sysadmin/comments/1kt167/system_administrator_wanted_humor/"&gt;most of the comments were at Reddit&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One comment noted "This is so close to reality that it is almost not funny anymore."  I agree, and as I explained in my own comment, the basis of everything I said was taken from real life: things that have happened to me or from conversations I've had with other people.&lt;/p&gt;
&lt;p&gt;For example, I have had someone insist that I had to be in two places at the same time.  Of course she didn't put it quite like that, but she did insist that I must go see two widely geographically separated customers, both of which had thorny sounding issues that might tie me up for many hours.  When I pointed out that I might not be able to do both, she simply kept insisting that I had to.  Of course I "had to" because she had promised both customers that they would see me that day.&lt;/p&gt;
&lt;p&gt;That the satire hit the mark is seen in that some people thought it was real.  The exaggerations do echo what seems to be a lack of respect for this kind of work.  Given the amount of responsibility the job carries, why is that true?&lt;/p&gt;&lt;h3&gt;No degree needed&lt;/h3&gt;
&lt;p&gt;According to Wikipedia,&lt;a href="http://en.wikipedia.org/wiki/System_administrator"&gt;only five schools offer graduate programs in system administration.&lt;/a&gt;. Although many more offer Information Technology or Computer Science degrees, those are often overkill for a sysadmin position: you don't need to know how to write N-way caching code to do this job!&lt;/p&gt;
&lt;p&gt;Indeed, ubiquitous computers have been here only a few decades, so many of the older folks doing this kind of work fell into it.  They knew a little about computers and as their company increased its complement, they became the "guy", which eventually formalized into some sort of title.  Those people sometimes get the least respect of all; &lt;a href="http://aplawrence.com/Opinion/missyouwhen.html"&gt;the company doesn't see them as a "professional"&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;It doesn't look hard&lt;/h3&gt;
&lt;p&gt;It is sometimes said that if the system administrator is doing their job well, they have nothing to do.  That's not entirely true: there will always be 
problems to deal with, but a good sysadmin is a bit like Smokey the Bear: they stamp out small fires that nobody notices so that they do not have to deal with major conflagrations.&lt;/p&gt;
&lt;p&gt;But there's more to it.  Much of the more visible (and time consuming) may involve user problems. To some eyes, this looks much like bringing your car to the mechanic: some mysterious thing under the hood isn't working, the grease stained guy in the blue shirt pulls a wrench out of his pocket and fixes it.  It's "blue collar" work, and while the reality is much different, that's what it may look like to upper management.&lt;/p&gt;
&lt;h3&gt;It doesn't look hard &lt;span style="font-family: Times, serif"&gt;II&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;People "fix" their own computer problems.  Everyone who uses a computer 
has probably fixed something, even if it was just adjusting a setting.  The 
sysadmin job may look like more of the same - it's something "anybody could do" - if they weren't tied up doing more important things!&lt;/p&gt;
&lt;p&gt;It probably doesn't help that sysadmins sometimes have to ask Google 
for help.  That knowing what to search for and knowing how to discard chaff in the results is a skill is irrelevant:  you didn't know how to fix it, so you looked it up.  Anyone could do that!&lt;/p&gt;

&lt;h3&gt;No tie needed&lt;/h3&gt;
&lt;p&gt;If the sysadmin is also charged with diving under desks or opening machines with a screwdriver, you are more likely to find them in jeans than a suit.&lt;/p&gt;
&lt;p&gt;Suit work gets respect.  Screwdriver work, even when what follows the unscrewing might require far more accumulated knowledge than many so-called "professional" jobs, does not get respect.&lt;/p&gt;
&lt;h3&gt;It doesn't seem critical&lt;/h3&gt;
&lt;p&gt;That may seem impossible to believe, but there is a certain amount of complacent disregard for the systems that really are the heart of most businesses today.  I think part of it is that computers are, after, just a tool.  In the minds of some, the real work takes place in their minds and the computer systems are nothing more than glorified screwdrivers.  Because they don't understand the technology that makes that screwdriver work, they tend to diminish its value.  Sure, there will be panic if the systems are not working, but the panic has its roots in the interference with THEIR work.  The sysadmin sees a downed server as a downed server, but the people who use that server see the down time as an impediment to their more important work.&lt;/p&gt;
&lt;p&gt;If the system gets no respect, either does the administrator.&lt;/p&gt;
&lt;p&gt;By the way, that Wikipedia article would make a good reference if you are a sysadmin and need to defend your value to a somewhat clueless boss.  You might iterate the duties you have and compare them to those listed there, but you might also point out this sentence from the "Skills" section:&lt;/p&gt;
&lt;pre&gt;
Perhaps the most important skill for a system administrator is
problem solving-frequently under various sorts of constraints
and stress.
&lt;/pre&gt;
&lt;p&gt;That's "knowledge work", not "screwdriver work". The stress is real and the constraints are real.  The skills are important, and worthy of good compensation.&lt;/p&gt;


&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Unixart/system_admin.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Want to showcase your product to our audience? Check our &lt;a href="http://aplawrence.com/advert.html"&gt;advertising options.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://samepage.io?partner=683d6fe8b2973c7cc2a4ba099fd949be56d864fe"&gt;Samepage - Redefining how people create and share information&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server, Firewall and more&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/aplawrence/DrTi?a=_oL4-LdHipk:TOiWlLpZgq4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/aplawrence/DrTi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
<link>http://aplawrence.com/Unixart/system_admin.html</link>
</item>
<item rdf:about="http://aplawrence.com/Basics/trapping_errors.html">
<title>Trapping errors in Bash  </title>
<description>Basics,Linux,Linux,MacOSX,MacOSX,Unix 

2013/08/19&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;!-- PLACEAD --&gt;&lt;!-- BIG LEFT --&gt;
&lt;br /&gt;
&lt;br /&gt;


&lt;p&gt;I want to begin with a warning.  The bash shell is really quite powerful 
and it is possible to do some amazingly difficult scripting using nothing more. &lt;/p&gt;
&lt;p&gt;If you have any doubt of that, reading Chris F. A. Johnson's &lt;a href="http://aplawrence.com/Books/shellscriptingrecipes.html"&gt;Shell Scripting Recipes: A Problem-Solution Approach&lt;/a&gt; would convince you.  If Chris can write crossword puzzles using shell scripts, there's probably not much that can't be done.&lt;/p&gt;
&lt;p&gt;That doesn't mean that you should.  Complex shell scripts can be very hard 
to understand, impossible to modify by anyone but a true expert and are 
not necessarily transportable. Those statements can be true for any 
computer language, but shell scripts often cannot be written clearly when they reach a certain level of complexity.&lt;/p&gt;
&lt;p&gt;The concepts demonstrated here don't reach that level, but I suspect that 
you'll see that they easily could.  If you want to dive in and push these 
ideas to the limit, you can certainly do so.  Just don't ask me to debug 
anything like that!&lt;/p&gt;
&lt;p&gt;With that in mind, let's trap some errors.&lt;/p&gt;
&lt;h3&gt;A simple trap&lt;/h3&gt;
&lt;p&gt;This is as simple as it gets:&lt;/p&gt;
&lt;pre&gt;
#!/bin/bash
trap 'echo Sorry, there was an error at line $LINENO' ERR
ls /etc/no_such_place_or_file 2&amp;gt;/dev/null
echo "foo"
ls /etc/no_such_place_or_file 2&amp;gt;/dev/null
&lt;/pre&gt;
&lt;p&gt;Upon invocation that will spit out:&lt;/p&gt;
&lt;pre&gt;
Sorry, there was an error at line 3
foo
Sorry, there was an error at line 5
&lt;/pre&gt;
&lt;p&gt;(Unless you have a file or directory named "/etc/no_such_place_or_file", of course)&lt;/p&gt;
&lt;p&gt;That's helpful. There is a slight problem, though: 
&lt;/p&gt;
&lt;pre&gt;
#!/bin/bash
trap 'echo Sorry, there was an error at line $LINENO' ERR
for x in 1 2 3 4 5
do
ls /$x/nosuchplace 2&amp;gt;/dev/null
ls /$x/someotherplace 2&amp;gt;/dev/null
done
&lt;/pre&gt;
&lt;p&gt;That always says the line number is the top of the loop&lt;/p&gt;
&lt;pre&gt;
Sorry, there was an error at line 3
Sorry, there was an error at line 3
Sorry, there was an error at line 3
...
&lt;/pre&gt;
&lt;p&gt;That's because any control structure (if, while, for, until, case) is seen as one multi-line command. There's no point to that example other than to show that.&lt;/p&gt;
&lt;p&gt;We can do something like:&lt;/p&gt;
&lt;pre&gt;
trap 'echo Sorry, there was an error at line $LINENO with $x' ERR
&lt;/pre&gt;
&lt;p&gt;and get:&lt;/p&gt;
&lt;pre&gt;
Sorry, there was an error at line 3 with 1
Sorry, there was an error at line 3 with 1
Sorry, there was an error at line 3 with 2
Sorry, there was an error at line 3 with 2
..
&lt;/pre&gt;
&lt;p&gt;Which is some help, but control structures will obfuscate your errors.&lt;/p&gt;

&lt;p&gt;We can get far more complicated:&lt;/p&gt;
&lt;pre&gt;
#!/bin/bash
function my_trap()
{
[ $1 -lt 15 ] &amp;amp;&amp;amp; echo bad bad line $1 error $2 with x at $x
[ $1 -ge 15 ] &amp;amp;&amp;amp; echo REALLY bad at line $1 error $2
}

trap 'my_trap ${LINENO} $? ' ERR

for x in 1 2 3 4 5
do
ls /$x/nosuchplace 2&amp;gt; /dev/null
done
echo foo

ls /100/foo 2&amp;gt;/dev/null
&lt;/pre&gt;
&lt;p&gt;Which should produce:&lt;/p&gt;`

&lt;pre&gt;
bad bad line 11 error 1 with x at 1
bad bad line 11 error 1 with x at 2
bad bad line 11 error 1 with x at 3
bad bad line 11 error 1 with x at 4
bad bad line 11 error 1 with x at 5
foo
REALLY bad at line 17 error 1
&lt;/pre&gt;
&lt;p&gt;Or, you can reset the trap:&lt;/p&gt;
&lt;pre&gt;
#!/bin/bash
function my_trap()
{
[ $1 -lt 15 ] &amp;amp;&amp;amp; echo bad bad line $1 error $2 with x at $x
[ $1 -ge 15 ] &amp;amp;&amp;amp; echo REALLY bad at line $1 error $2
}


trap 'my_trap ${LINENO} $? ' ERR
                     
for x in 1 2 3 4 5
do
ls /$x/nosuchplace 2&amp;gt; /dev/null
done
echo foo
trap 'echo Sorry, there was a somewhat important  error at line $LINENO ' ERR
ls /100/foo 2&gt;/dev/null
&lt;/pre&gt;
&lt;p&gt;Which yields:&lt;/p&gt;
&lt;pre&gt;
bad bad line 11 error 1 with x at 1
bad bad line 11 error 1 with x at 2
bad bad line 11 error 1 with x at 3
bad bad line 11 error 1 with x at 4
bad bad line 11 error 1 with x at 5
foo
Sorry, there was a somewhat important error at line 17
&lt;/pre&gt;
&lt;p&gt;What if you would rather bail out at the very first error?&lt;/p&gt;

&lt;p&gt;You could add a "set -e" at the top of your script.  That stops on 
any error, though, so a better way might be to add an "exit" in your 
trap function that is seen when and where you want it to be seen. &lt;/p&gt;
&lt;p&gt;Finally, traps aren't just for errors.&lt;/p&gt;
&lt;pre&gt;
trap "echo All Done" 0
trap OnExit EXIT INT TERM
&lt;/pre&gt;
&lt;p&gt;The bash man page has extensive (and quite complex) information about "trap" and all its gotchas.&lt;/p&gt;


&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Basics/trapping_errors.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Want to showcase your product to our audience? Check our &lt;a href="http://aplawrence.com/advert.html"&gt;advertising options.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://samepage.io?partner=683d6fe8b2973c7cc2a4ba099fd949be56d864fe"&gt;Samepage - Redefining how people create and share information&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server, Firewall and more&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/aplawrence/DrTi?a=zSEbm_Py-_g:RUnVwLrLKvw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/aplawrence/DrTi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
<link>http://aplawrence.com/Basics/trapping_errors.html</link>
</item>
<item rdf:about="http://aplawrence.com/Basics/ps_and_grep.html">
<title>'ps' and 'grep'  </title>
<description>Basics,Linux,Linux,MacOSX,MacOSX,Unix 

2013/08/16&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;!-- PLACEAD --&gt;&lt;!-- BIG LEFT --&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;p&gt;When faced with the task of finding something in "ps", old Unix hands will almost automatically type "ps -e | grep" and follow that with whatever they are looking for.  I can tell you that after so many years of doing that, it's almost reflexive.  We may know that there are other ways, but it's the old saying: walk too close to a habit and it will bite you.&lt;/p&gt;
&lt;p&gt;The good thing is that most of the time that habit just wags its tail and gives us what we want. Even when there 
is a playful little snap of the teeth accompanying the tail wagging, we're often doing that at the command line and can ignore any superfluous output.  It's when our grepping is buried in a script that the results may turn tragic.&lt;/p&gt;
&lt;p&gt;There are a LOT of things that can go wrong with "ps -e | grep".  I'll try to cover the most damaging things, but 
I might miss one or two.  If you take away nothing else from what follows, make it this: test scripts carefully and do not assume anything!&lt;/p&gt;
&lt;h3&gt;Some alternates&lt;/h3&gt;
&lt;p&gt;There are other ways to get processes matching some string.  For example, on Linux:&lt;/p&gt;

&lt;pre&gt;
# ps -C watcher
  PID TTY          TIME CMD
 9153 ?        00:00:00 watcher
# ps -C sshd 
  PID TTY          TIME CMD
 2246 ?        00:00:01 sshd
 5435 ?        00:00:00 sshd
 5577 ?        00:00:00 sshd
# pgrep -l sshd
2246 sshd
5435 sshd
5577 sshd
&lt;/pre&gt;
&lt;p&gt;But "-C" is different on Mac OS X:&lt;/p&gt;
&lt;pre&gt;
 ps -C sshd
ps: illegal argument: sshd
usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]]
          [-g grp[,grp...]] [-u [uid,uid...]]
          [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]
       ps [-L]
&lt;/pre&gt;
&lt;p&gt;OS X  ps has a -C flag, but it isn't for showing processes.  The "pgrep" will work, though.&lt;/p&gt;
&lt;p&gt;OS X has another little gotcha.&lt;/p&gt;
&lt;pre&gt;
$ ps -e |grep taskgated
 1403 ??         0:00.01 /usr/libexec/taskgated -s
 1432 ttys001    0:00.00 grep taskgated
&lt;/pre&gt;
&lt;p&gt;Most non-BSD Unix folk would have expected one line, not two.  To get that from OS X, add -c:&lt;/p&gt;
&lt;pre&gt;
$ ps -ec |grep taskgated
 1403 ??         0:00.01 taskgated
&lt;/pre&gt;
&lt;p&gt;There are other ways to get rid of unwanted lines. &lt;a href="http://www.faqs.org/faqs/unix-faq/faq/part3/"&gt;Section 3.10 of Unix - Frequently Asked Questions&lt;/a&gt; suggests&lt;/p&gt;
&lt;pre&gt;
 ps ux | awk '/name/ &amp;amp;&amp;amp; !/awk/ {print $2}'
&lt;/pre&gt;
&lt;p&gt;and you might see this:&lt;/p&gt;
&lt;pre&gt;
ps aux | grep something | grep -v grep
&lt;/pre&gt;
&lt;p&gt;This is a clever way (though harder to type):&lt;/p&gt;
&lt;pre&gt;
ps aux | grep [s]shd
&lt;/pre&gt;
&lt;p&gt;In case you don't see why it's because the "grep" line will contain "grep [s]shd" (with the brackets) which won't match what grep is looking for.&lt;/p&gt;
&lt;p&gt;But in all cases, watch your switches.  On Linux, for example:&lt;/p&gt;
&lt;pre&gt;
# ps a
  PID TTY      STAT   TIME COMMAND
 2833 hvc0     Ss+    0:00 /sbin/getty -8 38400 hvc0
 3257 pts/1    Ss     0:00 /bin/bash
 3271 pts/1    S      0:00 sudo su -
 3274 pts/1    S      0:00 su -
 3275 pts/1    S      0:03 -su
 5578 pts/0    Ss     0:00 -bash
 5584 pts/0    S+     0:00 screen -D -r
12201 pts/1    R+     0:00 ps a
# ps -a
  PID TTY          TIME CMD
 3271 pts/1    00:00:00 sudo
 3274 pts/1    00:00:00 su
 3275 pts/1    00:00:03 bash
 5584 pts/0    00:00:00 screen
12202 pts/1    00:00:00 ps
&lt;/pre&gt;
&lt;p&gt;Those would be identical on OS X!&lt;/p&gt;
&lt;p&gt;Before we get too deep into ps idiosyncrasies here, you may want to take a look at &lt;a href="http://aplawrence.com/Blog/B1011.html"&gt;I_WANT_A_BROKEN_PS&lt;/a&gt; and &lt;a href="http://aplawrence.com/Blog/B1012.html"&gt;How "ps" works and why&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Let's move on to  look at a scripting problem:&lt;/p&gt;
&lt;pre&gt;
#!/bin/bash
X=`ps -e | grep $1`
# -ec on Mac
echo $X
&lt;/pre&gt;
&lt;p&gt;Nothing wrong with that, right?  Look, it works:&lt;/p&gt;
&lt;pre&gt;
$ ./t.sh vim
1474 ttys001 0:00.00 /bin/bash ./t.sh vim 1475 ttys001 0:00.00 /bin/bash
./t.sh vim 1477 ttys001 0:00.00 grep vim 1462 ttys002 0:00.01 vim foops
&lt;/pre&gt;
&lt;p&gt;OK, what about this?&lt;/p&gt;
&lt;pre&gt;
$ ./t.sh taskgated
1480 aa ab bh dl ds dt ex me pj pt re sc t1 t2 tp tt xt zz 0:00.01 taskgated
&lt;/pre&gt;
&lt;p&gt;What's all that "aa ab bh" stuff?  Here, let's see if this helps:&lt;/p&gt;
&lt;pre&gt;
$ ls ??
aa	bh	ds	ex	pj	re	t1	tp	xt
ab	dl	dt	me	pt	sc	t2	tt	zz
&lt;/pre&gt;
&lt;p&gt;
You have to be careful with pulling in the output of "ps" and randomly echoing it. The "ps" lines for daemons will include a "?" in the controlling tty column, so if you did "x=`ps -e | grep whatever`", the returning line would have a "?" (on Mac OS X, two "??"). If your script then does "echo $x", the ? mark or marks will match one or two character file names that happen to be present in your current directory. As this is directory dependent, your script might appear to work correctly initially and then break later.&lt;/p&gt;
&lt;p&gt;You can get &lt;a href="http://askubuntu.com/questions/157075/why-does-ps-aux-grep-x-give-better-results-than-pgrep-x"&gt;unexpected results with "pgrep" too.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Another thing that can bite you is the width of the listing.  What you see with "ps" at command line is not necessarily what "grep" sees. &lt;/p&gt;
&lt;pre style="font-size:85%"&gt;
$ ps -e
# partial output
...
 1589 ??         0:00.01 /System/Library/Frameworks/CFNetwork.framework/Version
 1629 ??         0:00.23 /System/Library/CoreServices/System Events.app/Content
 1644 ??         0:00.39 /System/Library/Frameworks/CoreServices.framework/Fram
...
$ ps -e | grep .
...
 1589 ??         0:00.01 /System/Library/Frameworks/CFNetwork.framework/Versions/A/Support/cookied
 1629 ??         0:00.23 /System/Library/CoreServices/System Events.app/Contents/MacOS/System Events -psn_0_1069317
 1644 ??         0:00.48 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/
  Versions/A/Support/mdworker -s mdworker -c MDSImporterWorker -m com.apple.mdworker.shared
...
&lt;/pre&gt;
&lt;p&gt;Without more instructions, "ps -e" stops at your terminal width.  When it is 
piped, it does not.  That could lead to more matches than you expected.&lt;/p&gt;



&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Basics/ps_and_grep.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Want to showcase your product to our audience? Check our &lt;a href="http://aplawrence.com/advert.html"&gt;advertising options.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://samepage.io?partner=683d6fe8b2973c7cc2a4ba099fd949be56d864fe"&gt;Samepage - Redefining how people create and share information&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server, Firewall and more&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/aplawrence/DrTi?a=7g5zXtdQxlk:m00C70phn6o:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/aplawrence/DrTi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
<link>http://aplawrence.com/Basics/ps_and_grep.html</link>
</item>
<item rdf:about="http://aplawrence.com/Basics/tput_stty.html">
<title>tput and stty  </title>
<description>Basics,Linux,Linux,MacOSX,MacOSX,Terminals,Unix 

&lt;!-- PLACEAD --&gt;&lt;!-- BIG LEFT --&gt;

&lt;br /&gt;
&lt;br /&gt;2013/08/15&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Both of these have to do with your terminal. Either can be informational (telling you something about 
your terminal settings) or active (changing something).  For example, "tput" can control the position of 
the screen cursor:&lt;/p&gt;

&lt;p&gt;Try this:&lt;/p&gt;
&lt;pre&gt;
tput clear
echo "hello world"
echo "Input please"
tput cuu1
tput cuu1
tput cuf1
tput cuf1
tput cuf1
tput cuf1
tput cuf1
tput cuf1
tput el
read akey
tput clear
echo Thanks
&lt;/pre&gt;
&lt;p&gt;You can look up the things you can do in
"man terminfo". For example, "tput clear" will clear the screen,
while "tput cols" will tell you how wide your terminal is. &lt;/p&gt;
&lt;p&gt;Another useful resource is &lt;a hef="http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html"&gt;Colours and Cursor Movement With tput&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;On the other hand, stty controls things like "echo".  Let's say that you wanted 
to turn off character echo while reading a password.  You could do this:&lt;/p&gt;
&lt;pre&gt;
old=`stty -g`
stty -echo
read password
stty $old
&lt;/pre&gt;
&lt;p&gt;Why save the old stty settings?  It's so you can put them back to what they were.  If you just 
said "stty echo". you are assuming that's how it was previously set.  It might not be: if the script 
was called from an emacs session, echo would have been off and you would have turned it back on!&lt;/p&gt;

&lt;p&gt;You can set colors: &lt;a href="http://aplawrence.com/Linux/setting-colors.html"&gt;Using color in shell scripts (Linux, Mac OS X)&lt;/a&gt;, 
&lt;a href="https://groups.google.com/d/msg/comp.unix.sco.misc/SD46smD6Z6Y/qFw-kG60vDEJ"&gt;switch to a line drawing characer set&lt;/a&gt; and much more.&lt;/p&gt;
&lt;p&gt;A simple "stty sane" can often restore a garbled screen (see &lt;a href="http://aplawrence.com/SCOFAQ/FAQ_scotec8stuck.html"&gt;My screen is completely unreadable&lt;/a&gt; if that's not enough).&lt;/p&gt;
&lt;p&gt;You might also try "tput reset" and "tput init" (which may be indentica;l see "man tput").&lt;/p&gt;
&lt;p&gt;You can fix backspace confusion that comes up when telneting from Linux to SCO:&lt;/p&gt;
&lt;pre&gt;
   case $TERM in
        ""|unknown|dumb|dial*|tty|*ansi*)
            TERM=ansi
            ;;
        linux|xterm|rxvt)
            stty intr '^c'
            stty erase '^?'
            tput smpch
            ;;
    esac
    export TERM
&lt;/pre&gt;
&lt;p&gt;(From &lt;a href="https://groups.google.com/d/msg/comp.unix.sco.misc/e1yj3mEDY_w/UWTmFGsm8nUJ"&gt;Problem with backspace key when telnet from Linux&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;A common confusion for folks unfamiliar with SCO is that, by default, SCO systems set interrupt to the DELETE
key, not CTRL-C. If you find that unbearable, you can easily change
it; for example,&lt;/p&gt;
&lt;pre&gt;
 stty intr ^C
 
&lt;/pre&gt;
&lt;p&gt;will change your interrupt on Bourne or Korn shells. In this
example, you actually type CTRL-C; if you are in vi adding it to
your .profile, type CTRL-V and then CTRL-C&lt;/p&gt;
&lt;p&gt;This can also be added to .profile (or whatever startup file your
shell uses) or to /etc/profile.&lt;/p&gt;
&lt;p&gt;We'd use stty "hold-open" scripts to &lt;a href="http://aplawrence.com/SCOFAQ/FAQ_scotec7pflowcontrol.html"&gt;control settings on serial printers&lt;/a&gt; also.&lt;/p&gt;
&lt;p&gt;Flow control is also controlled by stty.  That's often needed for serial sevices, but even on virtual terminals you can pause output with Cntrl-S and (if stty ixany is set), restart it with any keystroke.&lt;/p&gt;
&lt;p&gt;Should you happen to be using a serial terminal for some reason, &lt;a href="http://linux.about.com/od/srl_howto/a/hwtsrl13t04.html"&gt;Linux Serial How-To&lt;/a&gt; may be helpful. Real serail terminal or not, "stty -a" will display its settings:&lt;/p&gt;
&lt;pre&gt;
$ stty -a
speed 9600 baud; 35 rows; 119 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
tony@Ant-echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
tony@Ant-extprocac:~$ 
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8
	-ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
	-dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = &amp;lt;undef&amp;gt;;
	eol2 = &amp;lt;undef&amp;gt;; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
	min = 1; quit = ^\; reprint = ^R; start = ^Q; st
&lt;/pre&gt;
&lt;p&gt;The 9600 baud is meaningless unless you really are on serial.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://aplawrence.com/Unixart/serial.art.html"&gt;Serial Wiring and Communications for the Confused&lt;/a&gt; might also be useful if you find yourself dealing with some ancient serial system.&lt;/p&gt;


&lt;p&gt;See also &lt;a href="http://www.tldp.org/LDP/lpg/node129.html#SECTION009223000000000000000"&gt;Terminfo Capabilities&lt;/a&gt; and  &lt;a href="http://aplawrence.com/Unixart/termcap.html"&gt;Termcap and Terminfo&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Basics/tput_stty.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Want to showcase your product to our audience? Check our &lt;a href="http://aplawrence.com/advert.html"&gt;advertising options.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://samepage.io?partner=683d6fe8b2973c7cc2a4ba099fd949be56d864fe"&gt;Samepage - Redefining how people create and share information&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server, Firewall and more&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/aplawrence/DrTi?a=PICk7pWg9uk:YLK_z3JzlOg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/aplawrence/DrTi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
<link>http://aplawrence.com/Basics/tput_stty.html</link>
</item>
<item rdf:about="http://aplawrence.com/Basics/basic_firewall.html">
<title>Basic software firewall introduction for home users  by firewall.  Understanding just a little bit about them can save you trouble.</title>
<description>Basics,MacOSX,Microsoft,Security 

2013/08/14&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;!-- PLACEAD --&gt;&lt;!-- BIG LEFT --&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;p&gt;Unless you have a very old computer, it probably has a "firewall" 
built into it.  That may be the Windows firewall provided with XP and on up  or the "Sharing" 
control on a Mac, or a firewall included with your antivirus software.&lt;/p&gt;
&lt;p&gt;What is it for?  It's to help keep bad things out of your computer
and also (with some firewalls) to keep your computer from doing bad things 
to someone else.&lt;/p&gt;
&lt;p&gt;But wait, you say: I thought that was what virus software does? Well, 
yes, but it's a little different.  Virus software examines things you 
bring into your computer (web pages, email) and tries to make sure 
they are safe.  It's like a parent checking the bag of Halloween 
candy their child brought home.  A firewall is a lock on the door: it 
stops things you don't want coming in at all.&lt;/p&gt;
&lt;p&gt;Take a very simple case: your printer.  You want to be able to 
print to it, of course, but you don't want me to be able to use it from
here, right? I could waste a lot of your paper and ink, couldn't I?
 A firewall is part of what protects you from that - and 
of course much worse.  If, for example, you just "hook up" to 
the Internet without any protection at all, your computer could possibly 
be "owned" within hours - sometimes minutes.  That is, someone could 
have hacked into it, taken control, and would probably use it as 
part of a vast network of such hijacked computers that are used for 
sending spam emails and other criminal purposes.  That's not 
a joke, not an exaggeration: it's real. You won't even know that your
computer is doing this, though it may run more slowly and "act up" more.&lt;/p&gt;
&lt;p&gt;So a firewall is a good thing.  But - particularly with the 
third party firewalls like those that come with Norton AntiVirus, 
McAfee and others, a firewall can also be the source of computer 
problems, glitches, and mysterious behavior.  When I am working 
at customers sites, I often find that misbehaving firewalls are 
the source of the problem I was called to fix.&lt;/p&gt;
&lt;p&gt;If something is odd, if your computer is suddenly acting strangely,
the first thing you might try is turning off the firewall if you have 
one.  How you do that varies, but third party firewalls often show 
up in your System Tray or at the top of your Mac screen; if you right click on them, a menu usually 
comes up that will let you temporarily or permanently disable them.&lt;/p&gt;
&lt;p&gt;
Windows Firewall can be disabled in Control Panel.  Often shutting 
off these firewalls fixes your problem instantly.&lt;/p&gt;
&lt;div style="text-align:center"&gt;

&lt;p&gt;&lt;a href="http://aplawrence.com/cgi-bin/showpic.pl?image=windows_firewall_lg.jpg&amp;amp;mytitle=Windows%20firewall&amp;amp;returnpage=Basics/basic_firewall.html&amp;amp;returntitle=Basic%20Windows%20firewall%20introduction%20for%20home%20users"&gt;&lt;img src="http://aplawrence.com/images/windows_firewall.jpg" alt="Windows firewall" title="Windows firewall (click for larger view)" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;

&lt;/div&gt;
&lt;h3&gt;Can you leave the software firewall off?&lt;/h3&gt;
&lt;p&gt;Well, that's a hard question to answer. Let's say that you turned on your computer 
this morning and found you could not send email.  Following my suggestion, you disabled the firewall and you CAN send email!  Wonderful - it's fixed!&lt;/p&gt;
&lt;p&gt;Well, no, not quite.  Something is wrong because your firewall should let you send mail. You 
should fix that or get someone else to do it.  If it's going to be someone else, turn the firewall 
back on and tell that person the whole story: mail works with the firewall shut off, but doesn't when it is on. 
They'll fix the firewall and you'll be fine again.  They'll appreciate you saving them some time, too.&lt;/p&gt;
&lt;p&gt;But shouldn't you be worried while it is shut off?  Again, a hard question, but it's usually fine, because 
most of you also have a hardware firewall: that router that your computer 
plugs in to.  That device is a firewall itself; you really absolutely, positively 
need a software firewall at home if you have a hardware firewall.&lt;/p&gt;
&lt;p&gt;Not sure what you have?  Here's how to tell: do Start-&amp;gt;Run 
and then type "cmd" (on older systems type "command").  That opens 
up a "DOS box", or "command window" as we old geeks call it.  In that 
box, type "ipconfig".  You'll get back something like this:&lt;/p&gt;
&lt;pre&gt;
Windows IP Configuration

Ethernet Adapter Local Area Connection:
       Connection-specific DNS Suffix:
       IP Address....................: 192.168.11.2

(and more, but it's the IP Address we want)
&lt;/pre&gt;
&lt;p&gt;On a Mac, you could open Terminal and type "ifconfig" or just look at the Network panel in 
Prefrences.&lt;/p&gt;
&lt;div style="text-align:center"&gt;
&lt;img src="/images/network_panel.jpg" alt="Mac network configuration" /&gt;
&lt;/div&gt;
&lt;p&gt;If that number ( 192.168.11.2 here) doesn't begin with 192, 172 or 10, you don't have 
a hardware firewall, and you need to shut your computer off, get up, and 
run to the store to buy one.  I'm not kidding: it's that important.&lt;/p&gt;
&lt;p&gt;I've really glossed over this subject - hardware firewalls are a very important 
part of Internet security - so important that the one I use costs over $900.00.
But I have special needs; all you need for typical home use costs $50.00 
or so.  It's a small price to pay for what you get. Installation is 
simple and they come with full instructions.&lt;/p&gt;
&lt;p&gt;Now, back to whether it's ok to leave the software firewall off.  It can be 
helping protect you, so if someone else put it on your machine, I'd say leave it.  That said, I 
only have the hardware firewall protecting my machines.  Admittedly, that is probably a much more sophisticated 
piece of equipment than what you got from Verizon or Comcast or whomever.&lt;/p&gt;
&lt;p&gt;If the software firewall isn't interfering with your use of your computer, I'd say keep it.  If 
it IS giving you grief, ditch it or replace it.
&lt;/p&gt;
&lt;p&gt;I do want to explain one likely difference.  Most low end hardware firewalls (like what you 
probably got from your ISP) only protect you from INCOMING threats.  Most do NOT stop your computer 
from doing OUTGOING things it should not be doing.  The software firewalls usually do protect that 
also.  That's possibly a good reason not to leave it disabled for very long. If your computer 
became infected by a virus, those outbound controls might (I said *might*) help stop it from 
sending out information or attacking other computers.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;The more geeky readers might enjoy &lt;a href="http://aplawrence.com/Security/valuefirewalls.html"&gt;The value of firewalls&lt;/a&gt;, whicch goes into this a bit more deeply.&lt;/i&gt;&lt;/p&gt;


&lt;p&gt;Comments: &lt;a href="http://aplawrence.com/cgi-bin/newcomm.pl?commenting=/Basics/basic_firewall.html"&gt;Click Here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Want to showcase your product to our audience? Check our &lt;a href="http://aplawrence.com/advert.html"&gt;advertising options.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Many of the products and books I review are things I purchased for my own use.  Some were given to me specifically for the purpose of   reviewing them.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;b&gt;I resell or can earn commissions from the sale of some of these items.  Links within these pages may be affiliate links that pay me for referring you 
to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain.  If you have any question, please do feel free to contact me.&lt;/b&gt;&lt;/i&gt;&lt;/p&gt;
&lt;div style="font-size:80%"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://samepage.io?partner=683d6fe8b2973c7cc2a4ba099fd949be56d864fe"&gt;Samepage - Redefining how people create and share information&lt;/a&gt;&lt;/td&gt;
&lt;td&gt; - &lt;/td&gt;
&lt;td&gt;&lt;a href="http://aplawrence.com/Kerio"&gt;Kerio Mail Server, Firewall and more&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/aplawrence/DrTi?a=zE-BTGLrarI:s8IclQdBeS0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/aplawrence/DrTi?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;</description>
<link>http://aplawrence.com/Basics/basic_firewall.html</link>
</item>
</rdf:RDF>
