Friday, October 31, 2008

11 Simple Ways To Recover Your Screen on Linux and Unix

Hey there,

If you're one of the many readers who submit a comment now and again (and even if you aren't ;), today's post is an homage to your helpful and insightful suggestions and tips. Some of you reading this right now may have emailed me with something that deserves to be posted as a comment to another post, and I can say, with great confidence, that it eventually will. I personally respond to all emails, so sometimes balancing that with work, family and more work can cause me to get a little behind. I'm still going to keep doing things this way, of course, not because I'm lazy or narrow-minded (okay, that's up for debate ;), but because I believe in actually responding to anyone who takes the time to send me a comment. And, just to clarify, this response-ethic of mine does not apply in any way shape or form to folks who write me one sentence vulgarities. If you want (or need) to hurl an insult my way, I strongly encourage it, but I probably won't write you back. Like with every other cycle, no matter who started it, someone has to end it :)

And, now, just to keep you on your toes, I'll include a hyperlink back to the original article on 9 simple ways to recover your screen in the same sentence that I let you know that this post is virtually the same material, only bigger, better and with extra sauce ;) Unless you want to read the rambling introduction (which is different in the original post), don't bother visiting the original page. All of the useful stuff from that post is included in today's version.

Once, again, a super-sized Thanks to everyone who wrote in with suggestions for this post and any other post. I truly appreciate your taking the time to write in and am almost always impressed, after a reading, with how much I don't know ;)

And, here we go again. Attribution for reader suggestions will accompany those points; otherwise, this post - from here on out - will be almost exactly the same as the last one.

Have a great weekend!

1. See if you can clear the screen the obvious way

host # clear

2. Or maybe resetting it might help

host # reset

3. stty is also usually available on most Linux and Unix distributions, and it has a sanity check built in. Worth a shot:

host # stty sane

4. tput is also fairly common. You can use it to clear your screen, or reset it, almost like the first two options did (just from a different angle):

host # tput clear

5. and...

host # tput reset

6. Or you can use it to re-initialize the screen (gross oversimplification, but you just want your screen back, right? ;)

host # tput init

7. Finally, you can try to get it to sort out the garbage on your screen by resetting the bold and underline definitions (this makes no sense to me at all, but it works sometimes;)

host # tput sgr 0 0

8. If your shell built-in echo can do this, it's fairly easy to take this route:

host # echo -e \033c

9. And, if it doesn't (or you just can't tell because your characters are still all goofed), you can type the control characters directly:

host # echo ^[c <-- Which, if you don't want to check out the link above, translates to typing: echo and then ctl-v followed by hitting the escape key and then typing the regular letter c

10. Suggested by Matthew Lenz! Here's a very simple way to get back your screen. Why does it work? I have no idea, but I tested it and it does on every machine I could try it out on :

host # cat /bin/cat

11. Suggested by James Ranks! One of these control key combinations will almost always work for you and remove the garbage from your screen (see point 9 for a link back on how to really represent control characters in Linux or Unix) :

host # ctrl-v followed by ctl-n

or

host # ctrl-v followed by ctl-o

Hopefully this little cheat sheet will come in handy at some time. You'll most likely be typing "in the dark."

Cheers,

, Mike



zcat made this comment regarding the post. It illustrates a good point: If things get too hairy, you have to know when to just bail and fix your terminal the old-fashioned way :)

I've catted plenty of binary files in the past and never needed anything
beyond 'reset' to recover from it. Perhaps I just got lucky.

But if I ever did need more than a reset, I think I would probably just
log out and back in at that point; the advantage of using a short
username like 'zcat' (and on the hosts where it's my full name I use
key-based authentication so I never have to type it)







Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Thursday, October 30, 2008

LVM's Roots - Mirroring Your Boot Disk On HP-UX 10 Unix

Hey There,

If you read this blog every once in a while (or if you just happen to have ever searched for - or queried the tag named - LVM in our growing library of questionably-valuable articles ;) you've probably noted that, although mentioned in passing, none of them has ever dealt directly with HP-UX. AIX and, of course, Linux have received their fair share of attention. Even Solaris Volume Manager (or, if you still prefer it, Solstice Disk Suite) and Veritas Volume Manager have been covered in some detail with reference to their similarity to LVM. It's about time that HP-UX (arguably one of the mothers of LVM (or LVM2) as we know it today) should get some sort of treatment. This blog is, after all, dedicated to Linux and Unix (both terms being purposefully generic so we can write about whatever *nix machines we can get our hands on :)

Today's entry is a bit of a quick introduction to HP's Logical Volume Manager and was written specifically for an HP-UX 10.x box. We haven't specifically tested this against 11.x or 11i, but, from our experience working with both, this script should work with little-or-no modification on 11.x. Now that we've got a few HP servers to have fun with (I mean... work really hard on ;), we'll give HP-UX it's due and run through the essentials of LVM. We'll try to make it as short and sweet as possible, while not skimming over the basics, so that the posts themselves can serve as a decent reference for a straight-up HP-UX user. Actually, if you're an HP-UX user (Experience here ranges from 9.x through 11i - Old 800 series K class towers ( with matching WYSE terminals) to SuperDomes and some of the newer 9000 series), you're also well familiar with the huge differences in the basic functionality between versions of the OS and the ISL and GSP/BCH underpinnings (which you could, somewhat, liken to a difference between the Domain Console/System Controller setup on the big Sun 3800 through 25k servers and the newer XCP/XSCF setup on the Mx000 series).

Until that day, here's a little script to help mirror your root disks on HP-UX 10. This was actually tested and used on a K100 Server (Refurbished, of course, but smokin' fast with 4 100 MHz CPU's. Actually, pretty decent once it boots up okay :)

Cheers,


Creative Commons License


This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License

#!/bin/sh

#
# hpmirrordisk.sh - Double check this before you run it. Seriously :)
#
# 2008 - Mike Golvach - eggi@comcast.net
#
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
#

echo "You have installed the MirrorDisk-HPUX Product already, right?"
echo "If you still need to, hit ctl-C and quit running this script!"
read oblig
echo
echo "This should show only one bootable disk to start out..."
echo
lvlnboot -v
echo
echo "New bootable physical volume name [c?t?d?]"
echo
read disk
pvcreate -B /dev/rdsk/$disk
echo
echo "Volume group you'll be mirroring [vg??]"
echo
read vgroup
vgextend /dev/$vgroup /dev/dsk/$disk
echo
echo "Making Mirror Disk Bootable..."
echo
mkboot /dev/rdsk/$disk
mkboot -a "hpux -lq (;0)/stand/vmunix" /dev/dsk/$disk
echo
echo "This result output should give you back \"hpux -lq (;0)/stand/vmunix\""
echo
lifcp /dev/rdsk/${disk}:AUTO -
echo
echo "Return to continue"
echo
read oblig
echo
echo "Extending all logical volumes..."
echo
for x in 1 2 3 4 5 6 7 8 9
do
/usr/sbin/lvextend -m 1 /dev/${vgroup}/lvol$x /dev/dsk/$disk
done
echo
echo "This should show two bootable disks now..."
echo
lvlnboot -v
echo
echo "Okay? Hit return"
echo
read oblig
echo
echo "For these tests, the Physical Extents should map to the"
echo "Logical Extents for each logical volume."
echo
for x in 1 2 3 4 5 6 7 8 9
do
echo
echo "lvol$x"
echo
lvdisplay -v /dev/${vgroup}/lvol$x |sed -n '/Distribution/,/Logical/p'|sed '$d'
echo
echo "Okay? Hit return"
echo
read oblig
done

echo
echo "All you need to do now is reboot and be sure to halt the"
echo "system at the boot menu. Make sure the Primary Boot Path"
echo "is set to the mirrored disk. If not, you will have to set"
echo "the correct path in the COnfiguration menu. Also, under the"
echo "COnfiguration menu, set Auto Search equal to ON."
echo "Finally, be sure to set the Alternate Boot Path to the"
echo "original disk"
echo


, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Wednesday, October 29, 2008

Pulling Info From IMDB Part One: Goofy Movie Titles

Hey There,

We're going off the range here today (while we leave another script on the oven to simmer for 24 hours ;) and moving along to finding the best way to strip "random-yet-connected" data from any online source.

The script should be fully tested by tomorrow, but for today we'll just be showing you what we've gotten it to produce so far (since it had to be manually massaged a bit).

This "project" will accomplish two simultaneous goals; neither of which will probably end up being for the betterment of mankind ;)

1. Scour the Internet Movie DataBase Main Search Hub-Page, using wget for Linux or Unix, and find all the movie titles that match our seed-pool of words or phrases.

2. Mix the real movie titles with fake movie titles culled from our seed-pool. For instance "Maximum Proposal" is a movie title created by combining two different members of our seed-pool. It's made up of two words which, when taken separately, appear in lots and lots of movie titles. Together, they're just completely ridiculous ;)

The result is, hopefully, as amusing for everyone else as it was (and is) for us :)

Cheers,



Stupid Movie Titles






Currently Reigning Champion


Baby Monitor: Sound of Fear






Presenting, in an ongoing attempt at maintaining alphabetical order, a collection of some of the worst and most uninspired creations of the military-industrial-entertainment complex.


Most are real, some I just made up.


If you can find all the fakes, treat yourself to a brand new couch!






(Yadda, Yadda, Yadda) Planet of the Apes


Afterthoughtfulness


Agony of Love: Lace and Lash


Ain't Love Cuckoo?


Aliens From Another Planet


Allergic to Love


Analysis of a Proposal


Analytical Instinct


Barn of the Blood Llama


Battle Taxi


Big Love - An Invitation to Disaster


Blood Arrow


Blood Church


Blood Diner


Blood Freak


Blood Kick: Kung Fu of the Five Hand Ninja


Blood Orgy of the She Devils


Blood Sucking Freaks


Blood and Donuts


Bloodsucking Pharoahs in Pittsburgh


Bloodthirsty Butchers


Bloody Hand Goddess


Bride of Chucky


Bride of the Monster


Brutal Carnage


Burning Sensation


Carpet Burn


Chased by Bloodhounds


Chronic Halitosis


Critical Motive


Cyberteens in Love


Dead Heat


Death By Dialogue


Death Car On the Freeway


Death Diploma


Death Fish


Death Goes To School


Death May Be Your Santa Claus


Death and the Compass


Decisive Impact


Deep Blood


Deep Fist


Deep Impact


Deep Rising


Deep Rub


Deep Sea Doodle


Devil Dog: The Hound of Hell


Double Impact


Dragonball


Drunk Driving


Dunston Checks In


Education High


Evil Mystery Friend


Evil Undead


Fatal Glimpse


Fatal Proposal


Fiduciary Responsibility


Final Debenture


Final Exam


Final Impact


Final Instigator


Final Instinct


Fist Fighter


Fistful of Fingers


Fistful of Fist


Forced Vengeance


Foxy By Proxy


Frank Proposal


Frankenstein: The College Years


Full Impact


Funky Monkey 2


Guilty as Hell


Gymkata


Happy Victim


Hard Impact


Headless Body in Topless Bar


Headless Eyes


Hollywood Chainsaw Hookers


I Know Where You Went Last Summer


Immediate Seizure


In Abstentia


Indecent Analysis


Indecent Impact


Insaniac


Instinctive Analysis


Instinctive Proposal


It's Alive III: Island of the Alive


It's Hummer Time


Judge the Bloody City


KickDancer


Kicked in the Face


Kiss The Blood Off My Hands


Kung Fu Master Named Drunk Cat


Let's Do Life


Leveraged Buyout


Liberal Helping


Live By the Fist


Living Bed of Blood


Lumbering Behemoth


Mad City


Maximum Analysis


Maximum Impact


Maximum Proposal


Maximum Risk


Maximum Surge


Mister Deathman


Mod F*** Explosion


Montgolfier of Death


Mr. Clean


My Friend, Flicka


My Giant


My Life As An Eggplant


My One Good Leg


Mystery Trellis


Night of the Bloody Transplant


Nolo Contendre


Petticoat Planet


Presumed Guilty


Psychomania


Punch and Judo


Quantum Deep


Reality Bites


Reefer Madness


Samurai Blood, Samurai Guts


Sensation Hunters


Sensitive Analysis


Sensitive Impact


Sensitive Instinct


Sensitive Proposal


Sensual Recluse


Sex, Blood and Mutilation


Shades of Love: Tangerine Taxi


Shoot Fighter


Sinister Overtones


Ski Lift to Death


Spencer: The Judas Goat


Steel Dawn


Stonestreet: Who Killed the Centerfold Model?


Street Gun


Street Justice


Streets of Rage


Sugar Mommies


Sugar and Plastic


Tap Daddy


Taxi Dancer


Taxi Girls


Taxi! Taxi!


Tech Support: Customers in Crisis!


Terminal Force


Terminal Impact


Terminal Justice


That Darn Cat


The Bloody Olive


The Camptown Suicide Club


The Drunken Shaolin Monkey


The Heavy Hand of Dr. Grubensteiner


The Hippy Dentist


The Last Few Minutes in the Life of Marty Birnbaum


The Lickerish Quartet


The Lift


The Psychedelics


The Sadist


The Schmoozer


The Secret Bloody Island


The Snapper


The Stone Fox


Three Men and a Chimp


Thundering Taxis


Triple Impact


Trust: Why Did You Kill Me?


Unmitigated Analysis


Violent Planet


Wacky Taxi


WaterWorld


What Price Taxi?


When A Stranger Calls


World of the Drunken Master


Would You Like Fries With That?


Young Pistols


Young Zombies


Zoomstone





, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Tuesday, October 28, 2008

Linux/Unix Shell Script To Find Your Google Page Rank

Hey There,

Today's entry may remind you of our older post on finding your Google index rank, but (aside from the word "rank" ;) it's a whole separate topic. Fortunately, or unfortunately, we still haven't put up enough posts to forget any of them yet :)

While our index rank script took a URL and a search term (or terms) and returned your relative index rank at that particular moment in time (e.g. It would let you know that your website was the 435th listing in a search for "fig trees," or something of that nature), this script focuses, simply, on the Google Page Rank (PR) of any specific URL. "Simply," as you'll see, is a matter of perspective. For instance, our script for today is fairly easy to follow. The actual deconstruction of Google's checksum algorithm (a "very" important piece of information if you want to get your Google PR) is somewhat complicated.

The URL checksum algorithm, itself, can be found on the web in PHP, ASM, C, C++, Perl, Python and many other variations, but no "shell" version of the algorithm exists (that we know of). And, that, (even though it will be a major PITA ;) is going to give us something to do for a while. For today's script, we are using a version we compiled from the (unmodified) source code of pagerank.c. This code is freely available via the preceding link and its author is only listed as the base of the URL in that link. We would like to thank http://zhiwei.li/ for writing this code and making it publicly available. Without it, we might have gone the easy route and used Perl's WWW:Google:PageRank module, saving a few hairs in the process ;)

NOTE: We've attached the pagerank.c code at the end of this post, after our bash script. We've also compiled it, and put it up for download on a separate server, for Cygwin kernel 1.5.25 and Ubuntu kernel 2.6.24-21 (Right click on either link and choose "Save As," since neither file has an extension, but both are binaries :) If you would like the binary compiled for your particular distro, send us an email (top right link) and we'll help you if it's possible :) If you prefer to build the binary from the attached source for yourself, you can do that with gcc (or your compiler of choice) very simply, as it requires no "special" arguments (just the c code file and an output file name), like so:

host # gcc -o pagerank pagerank.c

and you'll have the "pagerank" binary that we call from our script.

The script itself is even easier to use. If you want to modify it, note that the "pr_checksum_prog" variable is set to "./pagerank". If you've compiled the source to a different name or have placed it somewhere other than the same directory from which you run our script, that line will need to be modified accordingly (or, if you've downloaded from our alternate site, just copy your distro's binary from "cygwin1525_pagerank" to "pagerank" (or "ubuntu262421_pagerank" to "pagerank"). Assuming you've built (or downloaded) the binary, have it named "pagerank" and have placed it in the same directory as our script, you just need to do this to get any URL's Google PR:

host # ./prank.sh http://www.google.com
Google PR For http://www.google.com = 10
<-- Is it just us, or does this result seem biased? ;)

And that's all there is to it :) We promise we'll get back to converting the C checksum code into shell script as soon as possible. Google "does" change their URL checksumming algorithm from time to time, so, if you're reading this in the distant future, the code on this page may no longer be of any value. If (or, more realistically, "when" ;) it changes, we'll try to keep on top of it and publish the updated source.

Hope you enjoy this, or find some good use for it :)

Cheers,


Creative Commons License


This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License

#!/bin/bash

#
# prank.sh - Find any URL's Google Page Rank (PR)
#
# 2008 - Mike Golvach - eggi@comcast.net
#
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
#

if [ $# -ne 1 ]
then
echo "Usage: $0 HttpOrHttpsURL\n"
exit 1
fi

pr_checksum_prog="./pagerank"

if [ ! -x $pr_checksum_prog ]
then
echo "Cannot Find Checksum Program: $pr_checksum_prog !"
exit 2
fi

wget=/usr/bin/wget
prank_url=$1
mod_prank_url=`echo $prank_url|sed -e 's/:/%3A/g' -e 's/\//%2F/g'`
prank_checksum=`$pr_checksum_prog $prank_url|sed 's/Checksum=//'`

prank_qurl="http://toolbarqueries.google.com/search?client=navclient-auto&ch=${prank_checksum}&ie=UTF-8&oe=UTF-8&features=Rank&q=info:${mod_prank_url}"

echo -n "Google PR For $prank_url = "

$wget -nv -O - "$prank_qurl" 2>&1|grep "Rank_"|sed 's/Rank_[0-9]:[0-9]://'
exit 0



pagerank.c Unmodified Source Code


/******************************************************************************
Filename : pagerank.c
Description : Google PageRank Checksum Algorithm
Author : http://zhiwei.li/
Log : Ver 0.1 2005-9-13 first release
Ver 1.0 2005-10-19 fixed :final character bug
Ver 1.1 2006-10-05 refine code
Ver 1.2 2008-8-20 use boolean type
******************************************************************************/

#include <stdio.h>
#include <stdbool.h>

int ConvertStrToInt(char *pStr, int Init, int Factor)
{
while (*pStr) {
Init *= Factor;
Init += *pStr++;
}
return Init;
}

int HashURL(char *pStr)
{
unsigned int C1, C2, T1, T2;

C1 = ConvertStrToInt(pStr, 0x1505, 0x21);
C2 = ConvertStrToInt(pStr, 0, 0x1003F);
C1 >>= 2;
C1 = ((C1 >> 4) & 0x3FFFFC0) | (C1 & 0x3F);
C1 = ((C1 >> 4) & 0x3FFC00) | (C1 & 0x3FF);
C1 = ((C1 >> 4) & 0x3C000) | (C1 & 0x3FFF);

T1 = (C1 & 0x3C0) << 4;
T1 |= C1 & 0x3C;
T1 = (T1 << 2) | (C2 & 0xF0F);

T2 = (C1 & 0xFFFFC000) << 4;
T2 |= C1 & 0x3C00;
T2 = (T2 << 0xA) | (C2 & 0xF0F0000);

return (T1 | T2);
}

char CheckHash(unsigned int HashInt)
{
int Check = 0;
bool Flag = false;
int Remainder;

do {
Remainder = HashInt % 10;
HashInt /= 10;
if (Flag){
Remainder += Remainder;
Remainder = (Remainder / 10) + (Remainder % 10);
}
Check += Remainder;
Flag = !Flag;
} while( 0 != HashInt);

Check %= 10;
if (0 != Check) {
Check = 10 - Check;
if (Flag) {
if (1 == (Check % 2)) {
Check += 9;
}
Check >>= 1;
}
}
Check += 0x30;
return Check;
}

int main(int argc, char* argv[])
{
unsigned int HashInt;

if (argc != 2) {
printf("Usage: %s [URL]\n",argv[0]);
return 1;
}

HashInt = HashURL(argv[1]);
printf("Checksum=7%c%u\n", CheckHash(HashInt), HashInt);
return 0;
}




, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Monday, October 27, 2008

Get Your Local TV Listings From The Bash Command Line

Hey There,

For this week's Monday Linux/Unix bash shell script, we're finally starting to go after online TV listings. If you've checked out all of our other bash CLI scripts aimed at helping you to not have to open your web browser, please skip the following paragraph. It's redundant, to say the least ;)

Our previous web-based Bash scripts, in backward chronological order, include our posts on accessing Wikipedia, accessing the Farmer's Almanac, accessing the International Dictionary, checking out the world's weather, spewing out famous quotations on pretty much any subject, doing encyclopedia lookups, accessing the online Thesaurus, translating between different languages and, of course, using the online dictionary.

This script gets its content from TV Listings At Zap2It.com and accepts a maximum of two arguments. The US Zip Code is a required argument (we haven't checked to see if this works for overseas, but we highly doubt it, at this point) and you can also pass the script a "nohd" argument so that you only get standard TV listings returned. The default action, for this script, is to return all local television results (including HD Channels) for the current time period (Once we crack the dynamic object code, we'll definitely post an updated version of this script that will allow you to pick different "begin times" and also increase the time period your output can include). Also, you'll note that this script, again, includes a "pager" variable (which we've set to /usr/bin/more) since the output you get, if you don't pass the "nohd" option, will be extremely long and repetitive. You can edit that variable to set it to your favorite pager very simply. Otherwise, the script can be run simply, like so (one example command line per general execution mode):

host # ./localtv.sh 60015
host # ./localtv.sh 60015 nohd
<-- Strongly recommended for now, even if you have HD. It seems that most program listings are repetitious, although getting the output with the HD listings (default) can help you figure out what HD channels are broadcasting in your area.

Below are two pictures of the output (from the first two examples above - "60015" and "60015 nohd"). As you can see, we had to clip the HD version, since there are about 5 HD channels for every "regular" channel ;)

Click on the pictures below to be taken away to a place where things are slightly larger ;)

hd tv listings

tv listings without hd

I hope this script (in its infancy) is somewhat helpful or, at least, amusing for you ;) If you question the output, you can verify it by checking the TV Listings At Zap2It.com. It's highly possible that you may get output that we didn't get when running (literally, running ;) this script through its paces. Feel free to remove the 2 or 4 self-nullifying sed expressions in the script, as well ;)

Cheers,


Creative Commons License


This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License

#!/bin/bash

#
# localtv.sh - Get your local regular and HD Tv listings
#
# 2008 - Mike Golvach - eggi@comcast.net
#
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
#

numargs=$#
date=`date`
hour=`date "+%H"`
minute=`date "+%M"`
if [ $hour -lt 12 ]
then
if [ $minute -lt 30 ]
then
nicetime="${hour}:00 AM"
else
nicetime="${hour}:30 AM"
fi
else
let hour=$hour-12
if [ $minute -lt 30 ]
then
nicetime="${hour}:00 PM"
else
nicetime="${hour}:30 PM"
fi
fi

nohd=0

if [ $numargs -gt 2 ]
then
echo "Usage: $0 USZipCode [nohd]"
exit 1
fi
if [ $numargs -eq 2 ]
then
if [ "$2" == "nohd" ]
then
nohd=1
else
echo "Usage: $0 USZipCode [nohd]"
exit 1
fi
fi

args="$1"
wget=/usr/bin/wget
pager=/usr/bin/more
nicedate=`date "+%m/%d/%y"`

echo
echo "Television Listings for $nicedate - $nicetime"
echo

if [ $nohd -eq 1 ]
then
$wget -nv -O - "http://tvlistings.zap2it.com/tvlistings/ZCGrid.do?method=decideFwdForLineup&zipcode=${args}&setMyPreference=false&lineupId=PC:${args}" 2>&1|sed -e :a -e 's/<[^>]*>/ /g;/</N;//ba' |sed -e '/^[ \t]*$/d' |sed -e '1,/Forgotten password/d' -e '/isFavoritesAvailable/,$d'|sed -e '/[ECMP][SD]T/,+6d' -e "s/'/'/" -e 's/&/\&/' -e '/zc.getAdFrame/d' -e 's/^[ \t]*//;s/[ \t]*$//'| sed -n '/^[0-9][0-9]*$/,+2p'|sed 's/^\([0-9][0-9]*\)$/\n\1/'|sed '/^[0-9][0-9]*$/ {
N
N
s/ *\n/\t/g
}'|$pager
else
$wget -nv -O - "http://tvlistings.zap2it.com/tvlistings/ZCGrid.do?method=decideFwdForLineup&zipcode=${args}&setMyPreference=false&lineupId=PC:${args}" 2>&1|sed -e :a -e 's/<[^>]*>/ /g;/</N;//ba' |sed -e '/^[ \t]*$/d' |sed -e '1,/Forgotten password/d' -e '/isFavoritesAvailable/,$d'|sed -e '/[ECMP][SD]T/,+6d' -e "s/'/'/" -e 's/&/\&/' -e '/zc.getAdFrame/d' -e 's/^[ \t]*//;s/[ \t]*$//'| sed -n '/^[0-9][0-9]*\.*[0-9]*$/,+2p'|sed -e 's/^\([0-9][0-9]*\.*[0-9]*\)$/\n\1/'|sed '/^[0-9][0-9]*\.*[0-9]*$/ {
N
N
s/ *\n/\t/g
}'|$pager
fi

exit 0


, Mike




MikeS had this to add regarding the script. Some of it has been worked into our updated script and some of it will definitely be added to the to-do list!

Hey I love your local TV bash script. I only noticed one
problem it does not provide other options for example if you
have digital service through a local provider or say DISH. I
am pretty new to using bash and sed gives me a headache. I
noticed on their page that if you click on TV listing and
enter your zip code it gives you a list of options consisting
of "cable", "satellite" and "local." I wonder how hard it
would be to parse that out first then let the user select the
best option. I hard coded my option in to your code and it
works great so I can't image it not working well. If you
you're not interested in working on it that's cool. I'll just
have to delve into bash and sed to get it figured out maybe
throw in a little zenity. Anyway it's great. If i do make any
changes I'll bounce it back to you. oh there are some text
issues too. like how the & and " are displayed.

htmlspecialchars can be a pain to handle.

EDITOR'S NOTE: I'm leaving this part out and redirecting to our post on posting code on Blogger since trying to pull this off again makes me nuts ;)

Later,

Mike


Russ had this to add, which ended up being another major contributing factor in the update of this script!

I just took a look at the zap2it page; I see that the GET parameter in the URL for a selected time of 20:00 PDT today is: ?fromTimeInMillis=1225249200000. That appears to be Unix milleseconds from the epoch. (The page source shows a number of day/time values for that variable embedded in JavaScript.) I tried plugging it into the URL in the script and it ran just fine, giving me the 8:00 listing. So the object would be to obtain the proper millisecond value for the desired time from a script date argument. I know how to do that in Python, but not in the shell.

Regarding the 3-hour time block, it appears that all the data is on the page. Each program is in an HTML anchor, with the time in milliseconds given as a tag's "sch" attribute and the channel in a "chn" attribute. So it seems it would be possible to loop through each channel for the time periods and display each one with its clock time. That's quite a bit more complicated than the current script, though, and I don't think I'll tackle it. On the other hand, perhaps someday I'll give it a try in Python, which is my language.

Best,
-Russ


Russ also submitted these script add-ons:

Code for "clean.py"

#! /usr/bin/python
""" Converts HTML entities to their corresponding characters.
"""

import sys, htmlentitydefs, re

pattern = re.compile("&#?(\w+?);")

def descape_entity(m, defs=htmlentitydefs.name2codepoint):
# callback: translate one entity to its ISO Latin value
try:
return unichr(int(defs[m.group(1).strip('&#;')]))
except KeyError:
return unichr(int(m.group(0).strip('&#;')))

def descape(string):
""" Processes the string for HTML entities. """
return pattern.sub(descape_entity, string)

txt = sys.stdin.read() # Read the incoming text from the pipe
sys.stdout.write(descape(txt)) # Process and write to standard out


and code for "tube.sh" - Note that some settings are hard-coded

#!/bin/bash

#
# localtv.sh - Get your local regular and HD Tv listings
#
# 2008 - Mike Golvach - eggi@comcast.net
#
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
#

numargs=$#
date=`date`
hour=`date "+%H"`
minute=`date "+%M"`
if [ $hour -lt 12 ]
then
if [ $minute -lt 30 ]
then
nicetime="${hour}:00 AM"
else
nicetime="${hour}:30 AM"
fi
else
let hour=$hour-12
if [ $minute -lt 30 ]
then
nicetime="${hour}:00 PM"
else
nicetime="${hour}:30 PM"
fi
fi

args="97045"
wget=/usr/bin/wget
pager=/bin/more
nicedate=`date "+%m/%d/%y"`

echo
echo "Television Listings for $nicedate - $nicetime"
echo

# Get the HTML from the Web site and run through the common filters
$wget -nv -O - "http://tvlistings.zap2it.com/tvlistings/ZCGrid.do?method=decideFwdForLineup&zipcode=${args}&setMyPreference=false&lineupId=PC:${args}" 2>&1|sed -e :a -e 's/<[^>]*>/ /g;/</N;//ba' |sed -e '/^[ \t]*$/d' |sed -e '1,/Forgotten password/d' -e '/isFavoritesAvailable/,$d'|sed -e '/[ECMP][SD]T/,+6d' -e "s/'/'/" -e 's/&/\&/' -e '/zc.getAdFrame/d' -e 's/^[ \t]*//;s/[ \t]*$//' > fil

# Filter channels with no HD listings and direct to the display file (disp)
cat fil | sed -n '/^[0-9][0-9]*$/,+2p'|sed 's/^\([0-9][0-9]*\)$/\n\1/'|sed '/^[0-9][0-9]*$/ {
N
N
s/ *\n/\t/g
}'|egrep -Ew '^2|^6|^8|12|22|32|49' > disp
##else
# Filter channels with HD listings and append to the display file
cat fil | sed -n '/^[0-9][0-9]*\.*[0-9]*$/,+2p'|sed -e 's/^\([0-9][0-9]*\.*[0-9]*\)$/\n\1/'|sed '/^[0-9][0-9]*\.*[0-9]*$/ {
N
N
s/ *\n/\t/g
}'|egrep -Ew '^10' >> disp
cat disp |./clean.py |$pager
# Delete the files
rm fil disp
exit 0



Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Sunday, October 26, 2008

Ridiculous Resumes - Unix, Linux And Everything In Between

Hey there,

Last weekend, we poked fun at some of the insane want ads that companies put out when looking for IT talent. This week, to be fair, we're going to take a look at some of the goofy bloopers, funny blunders and (occasionally) serious bits of actual resumes that focus in on the unintentional humor that anyone who's ever had a part in the hiring process is familiar with. Sometimes, the things that people list on their resume is just downright scary ;)

We found a great comprehensive listing of some of the funniest resume jokes/goofs at The Job Mob's Resume Mistakes Page. It, in turn, cites various other sites on the web that contain even more humorous, but real, resumes. The names have been either changed or ommitted to protect the innocent, but probably most to protect the poster's @ss ;)

Hope you enjoy these, and have a relaxing Sunday :)




From
Resume Hell:



  1. “Career break in 1999 to renovate my horse”

  2. “1990 - 1997: Stewardess - Royal Air Force”

  3. Hobbies: “enjoy cooking Chinese and Italians”

  4. “Service for old man to check they are still alive or not.”

  5. Cleaning skills: “bleaching, pot washing, window cleaning, mopping, e.t.c”

  6. “Job involved…counselling clientele on accidental insurance policies available”

  7. “2001 summer Voluntary work for taking care of the elderly and vegetable people”

  8. “I’m intrested to here more about that. I’m working today in a furniture factory as a drawer”

  9. “I am about to enrol on a Business and Finance Degree with the Open University. I feel that this qualification will prove detrimental to me for future success.”

  10. “Time is very valuable and it should be always used to achieve optimum results and I believe it should not be played around with”

  11. “I belive that weakness is the first level of strength, given the right attitude and driving force. My school advised me to fix my punctuality…”


From Careerbuilder.ca’s
10 Wackiest Resume Blunders:



  1. Candidate included a letter from his mother.

  2. Candidate stated the ability to persuade people sexually using her words.

  3. Candidate wrote résumé as a play - Act 1, Act 2, etc.

  4. Candidate included naked picture of himself.


From
Amy Joyce on Resume Bloopers:



  1. “Skills: Strong Work Ethic, Attention to Detail, Team Player, Self Motivated, Attention to Detail”

  2. Woman who sent her résumé and cover letter without deleting someone else’s editing, including such comments as “I don’t think you want to say this about yourself here”


From
Ask Annie’s article about resume blunders:



  1. “an applicant ghosted a headshot as the background to her resume”

  2. Other Interests: “Playing with my two dogs (They actually belong to my wife but I love the dogs more than my wife)”.

  3. “One applicant used colored paper and drew glitter designs around the border”

  4. Hobbies: “getting drunk everynight down by the water, playing my guitar and smoking pot”

  5. Why Interested in Position: “to keep my parole officer from putting back me in jail”

  6. A woman had attached a picture of herself in a mini mouse costume

  7. Hobbies: “Drugs and girls”.

  8. Under “job related skills” - for a web designer - “can function without additional oxygen at 24,000 feet”.

  9. My sister-in-law misspelled the word “proofreading” in her skill set.

  10. The objective on one recent resume I received stated that the applicant wished to pursue a challenging account executive position with our rival firm.

  11. Objective: “career on the Information Supper Highway”

  12. Experience: “Stalking, shipping & receiving”

  13. “I am great with the pubic.”

  14. A candidate listed her e-mail address as pornstardelight@*****.com

  15. The applicant listed her name as Alice in the resume but wrote Alyce on the onsite application.

  16. One candidate’s electronic resume included links to her homepage, where the pictures were of her in the nude.

  17. “…sent out my resume on the back side of a draft of a cover letter to another firm…”

  18. “My duties included cleaning the restrooms and seating the customers.”

  19. One applicant for a nursing position noted that she didn’t like dealing with blood or needles.

  20. Achievements: “Nominated for prom queen”

  21. I once received a resume with a head and shoulders picture in the top left of the first page. The picture was of a lion’s head, wearing a coat, shirt, and tie.

  22. a resume… was printed on the back of the person’s current employer’s letterhead.

  23. One resume that came across my desk stated how the individual had won a contest for building toothpick bridges in middle school.

  24. A resume… had several grease stains and a smudge of chocolate on it

  25. Hobbies: “Having a good time”


From Careerbuilder.com’s
Top 12 Wackiest Resume Blunders:



  1. Candidate explained a gap in employment by saying it was because he was getting over the death of his cat for three months.

  2. Candidate’s hobbies included sitting on the levee at night watching alligators.

  3. Candidate explained an arrest by stating, “We stole a pig, but it was a really small pig.”

  4. Candidate included family medical history.


From Mainejobs.com’s
Avoid These Resume Bloopers:



  1. “nine-page cover letter accompanied by a four-page résumé”

  2. “One applicant tried to make an impression by using four different fonts, three ink colors and a variety of highlighting options on her résumé”


From ResumePower.com’s
Ten Classic Resume Bloopers:



  1. “Revolved customer problems and inquiries.”

  2. “Consistently tanked as top sales producer for new accounts.”

  3. “Planned new corporate facility at $3 million over budget.”

  4. “Seeking a party-time position with potential for advancement.”


From HotJobs’
Real-life Resume Blunders to Avoid:



  1. “I often use a laptap.”

  2. “Able to say the ABCs backward in under five seconds.”

  3. “I am a wedge with a sponge taped to it. My purpose is to wedge myself into someone’s door to absorb as much as possible.”


From Fortune Magazine via
HumorMatters.com:



  1. “Finished eighth in my class of ten.”

  2. “Received a plague for Salesperson of the Year.”

  3. “Reason for leaving last job: maturity leave.”

  4. “Failed bar exam with relatively high grades.”

  5. “Am a perfectionist and rarely if if ever forget details.”

  6. “It’s best for employers that I not work with people.”

  7. “Let’s meet, so you can ‘ooh’ and ‘aah’ over my experience.”

  8. “I have an excellent track record, although I am not a horse.”

  9. “You will want me to be Head Honcho in no time.”

  10. “I have become completely paranoid, trusting completely no one and absolutely nothing.”

  11. “Personal interests: donating blood. Fourteen gallons so far.”

  12. “Marital status: often. Children: various.”

  13. “I am loyal to my employer at all costs..Please feel free to respond to my resume on my office voice mail.”

  14. “Instrumental in ruining entire operation for a Midwest chain store.”


From
Resumania’s Archive:



  1. Job Duties: “Answer phones, file papers, respond to customer e-mails, take odors.”

  2. Interests: “Gossiping.”

  3. Favorite Activities: “Playing trivia games. I am a repository of worthless knowledge.”

  4. Skills: “I can type without looking at thekeyboard.”

  5. Employer: ” Myself; received pay raise for high sales.”

  6. Objective: “I want to play a major part in watching a company advance.”

  7. Experience: “Chapter president, 1887-1992.”

  8. Experience: “Demonstrated ability in multi-tasting.”

  9. Experience: “I’m a hard worker, etc.”

  10. Languages: “Speak English and Spinach.”

  11. Reason for leaving: “I thought the world was coming to an end.”

  12. Additional skills: “I am a Notary Republic.”

  13. Objective: “So one of the main things for me is, as the movie ‘Jerry McGuire’ puts it, ‘Show me the money!’”

  14. Skills: “I have integrity so I will not steal office supplies and take them home.”

  15. Objective: “To hopefully associate with a millionaire one day.”

  16. Skills: “I have technical skills that will take your breath away.”

  17. Qualifications: “I have guts, drive, ambition and heart, which is probably more than a lot of the drones that you have working for you.”

  18. Objective: “I need money because I have bills to pay and I would like to have a life, go out partying, please my young wife with gifts, and have a menu entrée consisting of more than soup.”

  19. Qualifications: “Twin sister has accounting degree.”

  20. Experience: “Have not yet been abducted by aliens.”

  21. Skills: “Written communication = 3 years; verbal communication = 5 years.”

  22. Objective: “I would like to work for a company that is very lax when it comes to tardiness.”

  23. Education: “I possess a moderate educatin but willing to learn more.”

  24. Education: “Have repeated courses repeatedly.”

  25. Salary requirements: “The higher the better.”

  26. Salary desired: “Starting over due to recent bankruptcies. Need large bonus when starting job.”

  27. Bad traits: “I am very bad about time and don’t mind admitting it. Having to arrive at a certain hour doesn’t make sense to me. What does make sense is that I do the job. Any company that insists upon rigid time schedules will find me a nightmare.”

  28. References: “Bill, Tom, Eric. But I don’t know their phone numbers.”

  29. Work experience: “Two years as a blackjack and baccarat dealer. Strong emphasis on customer relations - a constant challenge considering how much money people lose and how angry they can get.”

  30. Personal: “I limit important relationships to people who want to do what I want them to do.”

  31. Objective: “Student today. Vice president tomarrow.”

  32. Accomplishments: “Brought in a balloon artist to entertain the team.”

  33. Application: Why should an employer hire you? “I bring doughnuts on Friday.”

  34. Achievements: “First runner-up for Miss Fort Worth, 1982.”

  35. Reason for leaving: “Pushed aside so the vice president’s girlfriend could steal my job.”

  36. Special skills: “I’ve got a Ph.D. in human feelings.”

  37. Reason for leaving last job: “Bounty hunting was outlawed in my state.”

  38. Experience: “Any interruption in employment is due to being unemployed.”

  39. Objective: “To become Overlord of the Galaxy!”

  40. Objective: “What I’m looking for in a job: #1) Money #2) Money #3) Money.”

  41. Hobbies: “Mushroom hunting.”

  42. Experience: “Child care provider: Organized activities; prepared lunches and snakes.”

  43. Objective: “My dream job would be as a professional baseball player, but since I can’t do that, I’ll settle on being an accountant.”

  44. Awards: “National record for eating 45 eggs in two minutes.”

  45. Heading on stationery: “I’d Break Mom’s Heart to Work For You!”

  46. “I am a ‘neat nut’ with a reputation for being hardnosed. I have no patience for sloppywork, carelessmistakes and theft of companytime.”

  47. Experience: “Provide Custer Service.”

  48. Experience: “I was brought in as a turnaround consultant to help turn the company around.”

  49. Strengths: “Ability to meet deadlines while maintaining composer.”

  50. Work experience: “Responsibilities included checking customers out.”

  51. Work experience: “Maintained files and reports, did data processing, cashed employees’ paychecks.”

  52. Educational background: “Highschool was a incredible experience.”

  53. Resume: “A great management team that has patents with its workers.”

  54. Cover letter: “Experienced in all faucets of accounting.”

  55. Objective: “I am anxious to use my exiting skills.”

  56. Personal: “I am loyal and know when to keep my big mouth shut.”

  57. Job duties: “Filing, billing, printing and coping.”

  58. Application: “Q: In what local areas do you prefer to work? A: Smoking.”

  59. Reason for leaving: “Terminated after saying, ‘It would be a blessing to be fired.’”

  60. Personal: “My family is willing to relocate. However not to New England (too cold) and not to Southern California (earthquakes). Indianapolis or Chicago would be fine. My youngest prefers Orlando’s proximity to Disney World.”

  61. Resume: “I have a lifetime’s worth of technical expertise (I wasn’t born - my mother simply chose ‘eject child’ from the special menu.”

  62. Resume: “Spent several years in the United States Navel Reserve.”

  63. Qualifications: “I have extensive experience with foreign accents.”

  64. “I am fully aware of the king of attention this position requires.”

  65. References: “Please do not contact my immediate supervisor at the company. My colleagues will give me a better reference.”

  66. “Worked in a consulting office where I carried out my own accountant.”

  67. Accomplishments: “My contributions on product launches were based on dreams that I had.”

  68. Career: “I have worked with restraints for the past two years.”

  69. Experience: “My father is a computer programmer, so I have 15 years of computer experience.”

  70. Education: “I have a bachelorette degree in computers.”


JobMob Top 10



  1. Application: How large was the department you worked in with your last company? “A: 3 stories.” (Resumania)

  2. A resume listed a skill as “being bi-lingual in three languages” (Ask Annie’s)

  3. Background: “28 dog years of experience in sales (four human).” (Resumania)

  4. In the section that read “Emergency Contact Number” she wrote “911.” (Ask Annie’s)

  5. Candidate drew a picture of a car on the outside of the envelope and said it was the hiring manager’s gift. (Careerbuilder.com)

  6. Languages: “Fluent in English. Also I have been heard muttering Gibberish in my sleep.” (Resumania)

  7. “Directed $25 million anal shipping and receiving operations.” (ResumePower.com)

  8. On one of our applications, a girl wrote ” I’m 16, I’m pregnant and I can do anything.” At the same time she turned in her application, her boyfriend handed in his. On his: “Felony for breaking and entering.” (Ask Annie’s)

  9. “One candidate included clipart on their resume of two cartoons shaking hands.” (Ask Annie’s)

  10. Application: “On the line that asked what “sex” he was, he wrote “occassionally”.” (Ask Annie’s)


If you laughed, you’ll love the
50 Funniest Short Job Descriptions Ever.


This article is part of
Litemind’s Lists Group Writing Project.





, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Saturday, October 25, 2008

Unix - What Is It? More Linux/Unix Humor

Hey there, Hope your Saturday is getting off to a good start :)

For this week's attempt to find even more Linux, Unix and/or computer-related humour on the web, I ran across an entertaining 4 minutes of video called "Unix: What the heck is it?" It's attached to this post, below, but is also available on OrienteeringPro's YouTube Page.

I ended up downloading the video and converting it from flash to AVI, since no embedding code was available. I'm assuming it's okay to put it here, on this blog, with attribution and a link-back since sharing (on YouTube) for this video was set on and encouraged. If I'm mistaken and this video is your property, please contact me (via the email link at the top right of every page) and I'll be happy to take it down and replace it with a blue hyperlink (Not quite as enticing, but probably more economical ;)

NOTE FOR FOLKS WITH VERY LITTLE TIME ON THEIR HANDS: The funniest part of this video starts about 3 minutes and 5 seconds into the playback. Listen for: "But, you may ask, when will I ever need to use a Unix system?" It's a scene from a blockbuster hollywood movie most of us probably remember (even if we don't want to ;) and is yet another illustration of why computer usage in films can make you nuts if you're unable to suspend your disbelief to the extreme ;)

If the video is a bit choppy, I apologize. You can view it in its original format on OrienteeringPro's YouTube Page if it begins to annoy you.

Enjoy!



, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Friday, October 24, 2008

Creating And Deleting Local Zones On Solaris 10 Unix

Hey There,

Today's post is the final post in our quick series on dealing with local zones on Solaris 10. If you want to check the previous entries out, finish this paragraph. If you don't (or already have), just skip past this one :) The previous posts in this series have dealt with already-created local zones and how to create new file systems in a local zone on Solaris 10, modify filesystems in existing local zones and remove file systems in a local zone.

Today's "how to" is going to cover the bookends of this mini-series; creating local zones in Solaris 10 and destroying them.

NOTE: This notation is fairly obvious in this post (it was more appropriate in the following three), but I'll include it for completeness' sake. You have to be in the global zone to create or destroy a new local zone. See what I mean? ;) Also, resource/storage pools, etc, are outside the scope of this series of posts. If you're curious to learn a bit more about that aspect, check out our older series of posts dealing with using storage pools in Solaris 10. The link is to the final post, but all the preceding posts are linked to on that page; much like they are on this one.

Now, we'll go, step by step, through creating a local zone (up through the final "installation" phase) and, subsequently, undoing all of our hard work by destroying it ;)

1. First of all, fire up your old friend zonecfg and we'll get the party started. For our examples, we'll call our new local zone "DING" to maintain consistency with our other posts and we'll call our pool "CLOCK" (ding dong, yeah, it's sappy ;) You'll notice that you define the zone name when you invoke zonecfg, although just doing that doesn't actually "create" it, like so:

host # zonecfg -z DING <-- This is going to give you an error, but you can safely ignore it. Basically, the error just indicates that you're trying to configure a zone that hasn't been created yet. That's o.k., because we're just about to :)
zonecfg:DING> create

2. Next, we'll set up all of the minimally necessary parts of this local zone (note that we've already checked that enough resources (disk, IP, etc) exist in order for us to be able to install our new zone):

zonecfg:DING> set zonepath=/zones/DING/
zonecfg:DING> set autoboot=true
<-- I would recommend leaving this as "false" until you know you're good, but the worst that can happen isn't really all that bad, since a local zone caught in an auto-boot-loop won't cause you the same headache a straight-up box with the same issue would.
zonecfg:DING> add net <-- Notice how this puts you in a sub-menu, which shows up in the prompt. This happens for most device configuration and is pretty helpful if you have to walk away from your build for a while and come back to a screen where someone's hit enter 500 times ;)
zonecfg:DING:net> set address=99.99.99.1
zonecfg:DING:net> set physical=bge0
zonecfg:DING:net> end
<-- and this, universally, takes us back down (or up, depending on how you look at it) a menu, so we end up back at
zonecfg:DING>

3. Then, with the process just about completed, we'll assign the zone to the "CLOCK" storage pool (outside the scope of these posts, but you can checkout our older 4-part post on working with storage pools). Once that's complete, we'll verify our zone and commit the configuration, like this:

zonecfg:DING> set pool=CLOCK
zonecfg:DING> verify
zonecfg:DING> commit
<-- This writes the configuration, which, up until this point, is held in-memory.
zonecfg:DING> exit (or ^D [Ctrl d])

4. The last step in creating a zone isn't entirely obvious. The first time I did this, I thought I was done when I completed step three. The zone was created, I'd assigned it all of the resources it required (and tweaked all of those) and then verified and committed the zone. Alas, I was wrong, there was still one last thing left to do.

The final act, in creating and enabling your new local zone is to "install" the zone with the zoneadm command. This will not only re-verify all of your zone's resources, check and see if your new zone will run on your system (or any other, for that matter), but also installs all the necessary files in the local zone's root filesystem and creates all mount points as necessary. It's very simple to run and very easy to deal with (Although it may take a little bit more time, even if your setup is good :) - Just run it, simply, like this:

host # zoneadm -z DING install
Preparing to install zone email-zone
...
Zone DING is initialized.


And that's, basically, all you need to do to set up a local zone :) Of course, you should run "zoneadm -z DING boot," zlogin, etc, to boot the zone up, login and run your own tests, just to be sure everything is the way you like it. If you need to make any adjustments, you can still use zonecfg to modify your zone's configuration (theoretically ad infinitum).

Now let's get to work ruining it all, by destroying our local zone ;) It's actually very simple and only includes one "real" step. We'll do the first part, just do to be polite, and shutdown the zone before we destroy it, like so:

host # zoneadm -z DING halt <-- Totally unnecessary if you're going to utterly destroy your zone anyway

Then, all we need to do is run one command to end it all:

host # zonecfg -z DING delete <-- You can also use the -F flag if it won't go away. Note, also, that no commit is necessary, as it was when we created the local zone.

And there we have it; the poignant story a local zone from birth to death ;)

Cheers,

, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Thursday, October 23, 2008

Removing Local Zone File Systems On Solaris 10 Unix

Hey There,

Today's post is a follow-up to our very recent posts on modifying existing local zone filesystems and creating new file systems in a local zone on Solaris 10. Today, we're moving to completion with this simple how-to on removing filesystems on local zones. We'll follow up with another simple post on how to create and destroy (all in one) local zones on Solaris 10. Even though I can write 500 hundred words on why I can't write less than 500 words, that post should be short ;) It almost "has" to be!

NOTE: This note is the same as in the last two posts. Nothing has changed ;) For those of you who haven't read those (or find this post all on its lonesome ;) here it is: When removing existing filesystems on a Solaris 10 local zone, all changes must be made to the filesystem from the global zone (assuming that you originally mounted it from there)!

1. First things first; you can't unmount a filesystem from within a local zone if it was created in the global zone. As per our notation in the post on creating filesystems on local zones, this does not apply to NFS, NAS or any other remote-or-network-mounted filesystems. These are mounted directly from the local zone and, as such, can be unmounted directly from the local zone.

One interesting thing, if you have your filesystem set up under the local zone's root, is that it won't show up on the global zone's "df -k" or "df -h," etc output. If you want to see the mount from the global zone (assuming you forgot where you put it or you just want to make sure), you can find out what filesystems are mounted in your local zone, from the global zone, (at least, this is one way) by running:

host # zoneadm list -vc <-- To list out the zones on your system from the global zone (DING is our example zone).
host # zonecfg -z DING info <-- This will list out more information than you need. Basically, look for the line at the top titled "zonepath:" You can then look under that zone path to see your local zone's root filesystem mounts. Note that you could just use "grep" to find all the lines in /etc/vfstab that include your local zone's name.

2. Back to cold harsh (but mercifully swift ;) reality. From the global zone, simply unmount your local zone filesystem, like so:

host # umount /zones/DING/root/DONG

3. Then, all that's left to do is to remove the local zone from the overall zone configuration (we're assuming that you've unmounted all of "your" local zone's filesystems before continuing and executing the steps here :) Again, this can all be done very simply by using the zonecfg command:

zonecfg –z DING
zonecfg:DING> remove fs dir=/DONG
zonecfg:DING:fs> commit
zonecfg:DING:fs> quit


4. Okay; step 3 included a white lie ;) If you don't want to get error messages or, worse, cause your system not to boot properly, it's recommended that you remove the local zone filesystem entries from /etc/vfstab in the global zone, as well.

And now (I kind of promise ;) you should be all set :) We'll post that creation/destruction post very soon, if not tomorrow. After that, we'll get back to Linux, AIX or any Operation System other than Solaris 10. We try to keep a fair spread given the sheer amount of distro's the term "Linux and Unix" actually encompasses. On the bright side, this blog's subject matter could easily be much more vague ;)

Cheers,

, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Wednesday, October 22, 2008

Modifying Existing Local Zone File Systems On Solaris 10 Unix

Hey There,

Today's post is a follow-up to yesterday's post on creating new file systems in a local zone on Solaris 10. Today, we're moving on to a simple how-to on modifying existing local zones. As some of you may have noticed, with yesterday's post, I managed to blithely bypass the creation of the local zone we were working on. It's generally required that you create (or make) a local zone before you can add a filesystem to it ;) Although this topic is covered within our previous post on setting up Branded Linux zones in Solaris 10, we'll attack zone creation and initial setup at the end of this short series of posts, just so it has its own place and isn't presented in a, possibly, unfamiliar context.

Today's bit of work is a nifty trick because, although it seems that there should be some "special way" to modify an existing filesystem in a Solaris 10 zone, it's really about as simple, or as difficult, as you make it ( For this example, we'll be consistent with yesterday's post and have the "DING" local zone's "DONG" filesystem be of the type VxFS ).

NOTE: This caveat carries over from our previous post, as well. When modifying existing filesystems on a Solaris 10 local zone, all changes must be made to the filesystem from the global zone!

1. Log into your global zone again. This is generally just the "host" or what we used to think of (before zones or containers) as "the box" or "the computer." Then, check out the filesystem you want to modify, with "df -k|grep DONG" (or something similar), like so:

host # df -h|grep DONG
/dev/vx/dsk/DINGdg/DONGvol 6547824 24356 6523468 1% /DONG


2. Now, you can simply resize (shrink, grow, etc -- this part is heavily dependent on your filesystem and its capabilities) as you would normally. We've attacked the following procedure in much more depth in our previous post on adding and managing storage with Veritas Volume Manager, so we'll leave this example boiled down to the essentials. For our example, we want to add 10 Gb of space to the "DONG" filesystem. And, we can do so, just as simply as if we were modifying any other VxFS filesystem, like this:

host # vxresize -g DINGdg DONGvol +10g

3. And that's it! Now all we have to do is verify that the filesystem actually grew, by issuing the exact same command we did in step 1. It should be noted that we used "vxresize" specifically (rather than "vxassist -growby") so that we wouldn't have to run two commands to increase the capacity of the volume and grow the filesystem on it. Depending on your situation, you may need to do both separately, but you'll still be following standard protocol for whatever disk management tool you prefer to use, rather than modifying your method to suit Solaris:

host # df -h|grep DONG
/dev/vx/dsk/DINGdg/DONGvol 17033584 24356 17009228 1% /DONG


And, there you go. Simple as pie, and the work week is just about half over :)

Cheers,

, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Tuesday, October 21, 2008

Creating New File Systems In Local Zones On Solaris 10

Hey There,

A while ago (back in May, 2008, I believe), we took a look at working with storage pools using ZFS on Solaris 10. As we know, ZFS stands for the Zettabyte File System and not the Zone File System (which some folks think it does. Not criticizing. It makes more sense than a lot of other things you might get from those initials ;). The point being, we never stopped to take a look at zones and lay down some simple procedures for working with them. Since this blog attempts to serve as some sort of a reference (hopefully folks come here and find some help or usable information/advice), today I thought we'd start taking a look at Solaris zones. Today, we'll start looking at Solaris 10 zones by looking at "local zones." There are many important distinctions to be made between local and global zones in Solaris, but, for now, let's just leave the meaning as vague as possible. Global = All Zones. Local = Specific Zones. Perhaps I could make it simpler to understand than that. Suggestions are, of course, always welcome. But, enough dwelling on that...

Here's one of (I'm sure) many ways to add a new filesystem to a Solaris 10 local zone. Note that all of this work needs to be done "from" the global zone.

1. Once you've logged onto your global zone (usually just the main host name, like you would log in to any other zone-less version of Solaris), create the volume and filesystem "on the global zone" using standard filesystem creation commands. For this instance, we'll assume VxFS (the Veritas File System), but you could use any filesystem Solaris supports. If you are using VxFS, Solaris Volume Manager or however you prefer to do your disk partitioning and management, it's always a good idea to try to include the name of your local zone in the disk group, etc. This way, in the future, you'll never have to wonder what belongs to which when you have 15 zones on the same box!

2. Add an entry for your new local zone in /etc/vfstab file on the global zone. You should use best practice and make the mount point under /zones/MyNewZone/root. So if you wanted to add a filesystem name "DONG" to the "DING" local zone, your mount point would be:

/zones/DING/root/DONG

3. Now, still on the global zone, modify the "DING" local zone:

host # zonecfg –z DING
zonecfg:DING> add fs
zonecfg:DING:fs> set dir=/DONG
zonecfg:DING:fs> set special=/dev/vx/dsk/DINGdg/DONGvol
zonecfg:DING:fs> set raw=/dev/vx/rdsk/DINGdg/DONGvol
zonecfg:DING:fs> set type=vxfs
zonecfg:DING:fs> end
zonecfg:DING:fs> commit
zonecfg:DING:fs> quit


4. Next, mount your new "DONG" filesystem while still in the global zone:

host # mount /zones/DING/root/DONG

5. Now, hop on out of the global zone (or log out, whichever works for you ;). Then, login to the "DING" local zone and you should be able to see your new filesystem:

/dev/vx/dsk/DINGdg/DONGvol 6547824 24356 6523468 1% /DONG


NOTE: The only exceptions to the "create your local zones in the global zone ONLY" rule, have to do with NFS, and the like, filesystems. When you are adding a filesystem of this type to your local zone, you need to add it while "in" the local zone.

Tomorrow, we'll take a look at maintaining/modifying your new "DING" local zone. Until then, enjoy the peace and quiet :)

Cheers,

, Mike




Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.