Command of the Day

Casual and not-so-casual readers of this blog know I’m a Linux/Unix guy. I fire up the work peecee for e-mail; since moving to my new location a month ago, I don’t even do that anymore. My new cube has only one network connnection, and that is used by my Linux workstation, running a Gnome desktop and the Exchange web client for email. I am not hardcore enough to run a workstation in text mode; still, to me, windowing systems are merely facilities for opening multiple text windows.

It is handy to capture output from some text window and paste it into an email, or into some other file that I’m editing. Heretofore, I’d just use the mouse to select the text from one window, and the middle mouse button to paste it in. Yesterday I came across a neat little utility that promises to change this method. It’s called xclip; here’s its help screen:

Usage: xclip [OPTION] [FILE]…
Access an X server selection for reading or writing.

-i, -in read text into X selection from standard input or files
(default)
-o, -out prints the selection to standard out (generally for
piping to a file or program)
-l, -loops number of selection requests to wait for before exiting
-d, -display X display to connect to (eg localhost:0″)
-h, -help usage information
-selection selection to access (“primary”, “secondary”, “clipboard” or “buffer-cut”)
-noutf8 don’t treat text as utf-8, use old unicode
-version version information
-silent errors only, run in background (default)
-quiet run in foreground, show what’s happening
-verbose running commentary

So, to get that help screen into this post, I just typed
xclip -h 2>&1 | xclip
I then used the middle mouse button to paste the stuff. No more grabbing one line too many, one line too few, etc. Precision. I like that.

Little utilities like this fascinate me. There’s room in my toolbox for xclip.

-k-

Exotic Environment Variables

One simultaneous curse and blessing of having worked with Unix systems for lots of years is that I encounter features and programs that I’d heard of, but never explored in any fashion. These encounters are uniformly all fun, after I realize what not-used feature had bitten me in the butt.

And so it was last week, I was compiling openssl, to get the latest libraries to link with a new version of openssh. And I was cruising; ssh RPMS were done for RHEL4 and RHEL5 in both 32 bit and 64 bit. Then I moved to the Itanium version, where the openssl piece simply refused to compile. A look at the debug output and Makefile, and I was able to reduce my problem to a one-line shell script; the referenced crypto directory existed in my current working directory. Observe the bold parts of the following:

#!/bin/bash
( cd crypto && echo "current directory is $(pwd)" )

Worked as expected.
#!/bin/sh
( cd crypto && echo "current directory is $(pwd)" )

failed with:
./x: line 2: cd: crypto: No such file or directory

WTF?? I could cd into crypto, see the files therein, and couldn’t begin to fathom what the problem could be. And, /bin/sh was a symlink to /bin/bash. I knew bash behaves differently depending on how it’s invoked. A look at the bash manpage provided no enlightenment.

This situation had to be solved; there could potentially be a number of third-party scripts which could fail in bizarre ways. I concluded, erroneously as it turned out, that the problem was Itanium-specific, and opened a ticket with Red Hat. The little script behaved properly on their Itaniums. A few straces later, and RH and I concluded that the environment on the offending system was at the heart of the problem.

I then began unsetting environment variables by hand, one at a time, and trying my little script again1. And, at long last, I unset CDPATH, ran the script again, and Voila!, this little fracas was over. Setting CDPATH on systems where “it worked” before caused an identical failure.

A little CDPATH research revealed, from the bash manpage:

CDPATH The search path for the cd command. This is a colon-separated
list of directories in which the shell looks for destination
directories specified by the cd command. A sample value is
“.:~:/usr”.

And, from the bash in POSIX mode docs, which happens when #!/bin/sh is line 1 of your script:

19. If `CDPATH’ is set, the `cd’ builtin will not implicitly append
the current directory to it. This means that `cd’ will fail if no
valid directory name can be constructed from any of the entries in
`$CDPATH’, even if the a directory with the same name as the name
given as an argument to `cd’ exists in the current directory.

I’ve known that CDPATH exists for close to 20 years. Never used it. A coworker had set it globally in some profile. He’d been working with Oracle RAC, and there are a boatload of uniquely named directories under /usr/local, or wherever. This artifice made his life easier, but at the cost of sacrificing an out of the box system, that behaves as one is used to. I can’t fault him. Had he included a “:.” in CDPATH, everything would have worked as expected. Or have set CDPATH for his sessions only.

I’m an old timer; I run as close to a default vanilla system as prudence allows. I have two aliases defined in my profile, which pass different options to ssh. I learned this via the school of hard knocks, back in the day when I’d aliased rm to rm -i, and then got on a system where it wasn’t so aliased, and watched an hour’s worth of work go down the tubes, as I typed rm *, and expected to be prompted a file at a time.

Once burned, twice shy. Nevertheless, episodes like this are what makes being a sysadmin an absolute hoot.

-k-


1 Remember the MacOS days, when you had to turn off OS extensions one at a time to figure out which one had bricked your system? Shudder.

Blinded

My yet-to-be-installed-or-ordered Linux Test Lab had been reduced to a single node for the time being.

SWMBO and friend visited Next Day Blinds, in search of new vertical blinds for the newly spiffied up tbbs-land World HQ, Control Center, and teevee room. Let me explain that WorldHQ has sliding glass doors going out to the patio, and the room opens to the second level of the house above. There are two patio-door-length windows there on the second level, also in need of treatment. Let’s just say that the down payment on these vertical binds would have bought a better Linux Test Lab than I envisioned in the first place. Not to mention the fact that SWMBO and friend have captured the #1 position in the post-home-improvement expenditures. I’ll gladly surrender the position.

The Next Day Blinds guy will be here to measure in a half-hour.

-k-

Technorati Tags:

GTD – GID1

Dave Slusher writes of his struggles with GTD. He provides pointage to a David Allen/Merlin Mann podcast that said:

it takes two years to really get the GTD system internalized.

After reading Dave’s post, I see that he and I are in approximately the same GTD status: we both have Hipster PAA cards out the wazoo, an we’ve both been dutifully adding more day by day. In both our cases, we’ve not progressed steadily on the processing of that information.

I’m using the PAA as input into my Palm PDA, and to do information has been flowing smoothly. I look through the balance of my cards, and find that what needs to be handled is the reference type information (the command to initiate a Linux kickstart from an Open Firmware prompt, stuff like that). The plan is to transfer this info from cards, to properly categorized Palm memos. The Missing Synch for Palm OS does a wonderful job in synching everything from the Palm to a Mac-based desktop. Contact info goes to the Mac’s address book, calendar info to the calendar, etc. Plus, and this is a big plus, categories are created on the fly; for example, if you see a need for another to-do category, create it on the Palm, add the to-do, and Missing Sync will create the item and the category on the desktop at the next sync. Prior versions had a catchall category to lump items, and it was a real pain to have to edit items after a sync, just to get them properly categorized.

So, I’ve got all the tools, I know what needs to be done, and like Dave, I just need to do it. Once caught up, I think the daily portion will be easily maintained. And Dave has it right; pick a time for daily review (with the AM java is a great time), and weekly review (weekends are a great time), and then just do it, dammit.

If it takes two years to get this process internalized, there’s no time like the present to start.

-k-

1 – GID = Get It Done, not the gid in the Unix sense. And not GED, in the Larry the Cable Guy Sense.

Technorati Tags: ,

Bless me Father, for I have Sinned

Made a trip to a nearby Borders Books this AM, in search of a couple of Linux books. Found those1, and meandered through CD-alley, just killing time, with SWMBO out of town and all. And then, browsing past “Country”, I saw it there, Not a Moment Too Soon, by, forgive me, Tim McGraw. There’s only one song on the CD I like, and it’s not available on iTunes last I checked. This may be the only McGraw song I like; it’s called Refried Dreams.

I’ve heard the song on Pandora, but unfortunately wasn’t running Audio Hijack Pro at the time. So, at $9.99, the CD came home with me. For one song.

I’m down here in Mexico,
Sick as a dog.
My head is poundin’ in this bordertown fog.
Down to my last dime
And comin’ apart at the seams,
I’m messed up in Mexico,
Livin’ on refried dreams.

Good gravy, I love those lyrics. Suggestions for penance are welcome.

-k-
1 – Linux Cookbook, and Linux Server Hacks for the geekologically curious. Yep, both from O’Reilly.

About Your Host

Ken
Name: Ken Nelson
Location: Reston VA, US, Earth
Occupation: Linux and Solaris System Administrator
Married: Nearly as long as I haven’t been
Children: 2, one living
Grandkids: 4, 2 of each gender
Fun Stuff: NASCAR
Politics: libertarian
Religion: Lutheran
NASCAR Driver: Kevin Harvick
Memorable Moment: Meeting Paul Prudhomme in the Big Easy
Birthplace: Kansas
Best Place I’ve lived: Kansas
Spiffy t-shirt: Evil Genius Chronicles
Influential person: My dad
Thing I’d most like to do: Night race at Bristol
Beer: Free is preferable. Cold and within reach works.
Scotch: Single malt, 12+ years, neat
TV: Prison Break.
Music: Country, steel guitar and twang.
Music #2: Real country is alt.country, or Texas country, thanks.
Best Rock song ever: Rock & Roll Woman, Buffalo Springfield
Food: BBQ, pork, Carolina-style. Slaw on the side.

Last update: Sat Aug 29 11:50:04 EDT 2009