Monday, March 26, 2007

Unix, pipes, scripts, oh my!

Let me show the power of the shell! There some things that you just can't do clicking a mouse or pecking on the keyboard stretching your fingers between letters and the alt or ctrl keys. Cron and at are you friends along with pipes. I work a lot on remote terminals at the command line and have become quite competent, even writing a few short scripts that do quite a lot. I'm not familiar with the latest version of Windows shell Monad so I won't compare it and just stick to what I know.

Let's try this, say you want a directory listing of everything in your home folder. Well in Windows you would open up your My Documents . But that doesn't save it in file, it just shows it to you. What about the command prompt, Start->Run->cmd enter in "dir" and there it is. But that still isn't in a file; okay copy, open notepad, paste it in. Now you have your home folder listing in a file. Bash or csh or ksh is much easier!

cd ; ls -l >> myhome.txt

That's it. cd changes directory to your home, ls -l gives a directory listing in long format, >> is the redirect command. Redirect takes the output from a command and sends it somewhere else. Usually it's used to create log files, here it takes the output and saves it in a file. Sometimes output is sent to the null device /dev/null; this will just send it nowhere. Redirect can also work the other way as in sending an input file to a command for processing.

Here is a common command I use:
ps -ef | grep db2
Here I use the pipe. Pipes are used usually in a chain of commands, the output of one command is used as the input for the next command. In the example I take the output of the ps command, process, and send to grep, pattern searching, looking for anything containing db2. You can add any number of commands to chain as long as it makes sense:
tail -f `ls -tr *backup* | tail -1`
This chain will get the most recently modified file that has backup in the name. The back ticks will return the commands between them. In effect tail -f will wait for ls -tr *backup* | tail -1 to execute and use the results in the command. tail -1 returns the last line of ls -tr *backup*. Adding it up the command will continously display the contents of the latest backup file.

Normally ps returns process sorted by their id, suppose we want the only db2 process sorted by name saved in a file:
ps -ef | grep db2 | sort >> db2process.txt

Let's find out who has an account
cat /etc/passwd | cut -f 1 -d : | sort
cat just spills out the contents of a file, sends the output to cut field 1 delimited by ":" and then sends it sort.

Command chains can become quite cryptic and long:
cd dba ; tail `ls -tr *backup* | tail -1` | (grep Finished && ls -ltr *backup*) || (tail -f `ls -tr *backup* | tail -1`)
My favorite, because I wrote it, change to the dba directory and tail the most recent backup file looking for "Finished" then show the listing otherwise keep tailing the file.

More to follow...








Tuesday, March 20, 2007

Job search

It's now six months since graduation and still no closer to getting a
better job. Health insurance is over $300/mnth and students, which
payments start in May, are almost $200. Every month we barely make it
from month to month so either I need a another deferment or someone
needs to offer me a job. My wife stays sick with worry all the time,
she's under the belief that we'll end up dropping the health insurance.
At first I was sure I would have found a better job before 2007, now I'm
not sure if anything will come our way. If anyone has a lead for either
a programmer (.NET or Java ), web developer or something similar in the
Lexington, KY or eastern KY area, leave me comment.

:-\

Sunday, March 18, 2007

Soapbox time

It's time to step onto my soapbox and address a couple of issues

1. *Linux vs Windows vs OSX*: Anyone who thinks Vista is the best OS
out there is just plain blind. I haven't used Vista except an
early beta in 2003 so I really can't comment too much about it but
judging by the spec and min requirements it just doesn't bode
well. OSX has received nothing but praise since 10.1 ( 10.0 was
crappy, this I know because my wife's iMac came with it ). Apple
has kept it under close quarters to maintain its' quality and has
done a good job. Microsoft has bent to the will of the big
corporations and ignored the home market, the DRM built into the
system and the laughable User Access Control have added to the
bloat of an already bloated system. Now for Linux! It is the up
and coming player. The linux distros have consistently improved
over the last few years. Desktop enviroments, security and
hardware support continue to improve. What other OS has builtin
support for virtualization? Not only can you keep the kernel and
drivers up-to-date but most software as well.
2. *Music, RIAA and WebRadio*: The music industry has shot itself in
the foot. Instead of embracing the new technology of the internet
and digital music they chose to fight it in the name of profits.
CD sales have dropped while downloads from the likes of iTunes and
others have risen. They are attempting to kill any young upstart
from stealing the pennies from their jars by having unfair rate
imposed on online stores and internet radio stations.
3. *Corporate America*: Two newscaster have become my favorite
spokesman: Lou Dobbs and Keith Olbermann. They have spoken up in
favor of the little guy, pointing out every time that big
companies try to squeeze the common working class. Insurance
companies, pharmaceuticals and others who revere profits at all
costs. Why is it mandatory to have auto insurance and not medical
insurance? I would think medical coverage is more important, why
doesn't the government regulate it?
4. *Security and freedom*: Which is more important? Is there a
balance? Should the administration be allowed to do anything in
the name of security? Hell no! This country was built on the
foundations of freedom and to do any less is unamerican. That is
the price we pay to have freedom of speech. /We/, as a population,
have an unspoken duty to report anything suspicious to the proper
authority, /we/ are honor bound to watch each other's back and to
protect our rights from outside influences.
5. *Dictator*: /A ruler who is not restricted by a constitution,
laws or any opposition.

http://www.google.com/url?sa=X&start=4&oi=define&q=http://www.saburchill.com/history/hist003.html&usg=__-R9IOQoxOY7qLRkIZnSwfbv3z2w=

/This is our president, he expects everyone to just follow along
with his judgement. It's been proven that he prefers loyalty to
competence; Iraq, Katrina, CIA leak. If you show that you'll go
along with him he'll reward you. He refuses to listen to anyone
else's opinion.

Prospective employers please read this!

This is my cover letter/intro in a more informal setting. I am currently
working as a level 2 support tech supporting both Windows and Unix
servers. I have been working on remote systems using Remote Desktop and
command line/shell commands. I have written a couple of scripts to save
time and allow me to watch other monitors. I have written a program to
consolidate notes for various accounts. This program also stores the
many passwords we have to have for the accounts we monitor. It also
makes automatic backups of notes and passwords with a time/date stamp.
There is an option to paste either as plain text or formatted. Using the
scripts/programs I wrote I have cut down the time to do repetitive task
by over half. This is the sort of employee you need, looking for ways to
save time and money.

I have proven leadership skills. Eight years in the U.S. Army, the last
four years in a leadership position. I graduated in the top 20% of a
class of over 500 students in the Primary Leadership Development Course.
I was chosen above my pears for a position designated for a higher rank
than what I held as Training NCO. The position covered training
schedules, files, records, making phone calls/appointments for the Unit
Command and First Sergeant, physical security and Information/Automated
System security, ensuring all clerks were properly trained. While
deployed to Kuwait in 2002 I was chosen to lead a team at the Forward
Deployed Headquarters. We were in charge of monitoring several long
range RADAR and satellite images and reporting anything to the Forward
Commander.

Before being in the Army I was a shift manager for a family restaurant.
I worked there for ten years, working my up from busboy to shift
manager. I was in charge of thirty employees, scheduling, food costs,
ordering and inventory and of course customer service.

I am ready for any challenges.

Saturday, March 17, 2007

The scourge of software

Here's another stick in my craw: the fact that you can't buy a pc without having freakin' MS all over it! Why not? wouldn't it be cheaper? Someone is getting paid or is so afraid of losing sales and getting on the wrong side of Microsoft.

First post

So here I am, starting my first blog. I needed a release for the frustrations that have been plaguing me lately. For starters there is the fact that I am still working the same blue-collar IT job for the last three years even though I have ten years as a shift manager in a family restaurant, over eight years in the Army ( the last three as a non-commissioned officer ), a degree in IT and three years doing level 2 support for a global tech company ( I won't mention their name but they are beating the crap out of SCO ). It's been six months and still nothing. What the hell is going on? Does anyone think I'm not qualified? Visit my online resume, and tell me what you think. I visit all of the job sites; Monster, Dice, America's Job Bank, Careerbuilder, and Craig's List. Is there something I'm missing? My student loans are coming up and guess what, I don't qualify for economic hardship. WTF!!! I'll have to drop our health insurance to make the payments. Where are all the jobs? I'll tell you, pick up the phone and call tech support and see who answers the phone. Outsourcing is killing the job market. I don't mind it if it's a global company and they use workers from that country; I'm all for that.