Linux Blog

When not to script it

Filed under: General Linux,Linux Software — TheLinuxBlog.com at 10:37 am on Wednesday, December 2, 2009

I’ve come across a number of programs in the past and thought to myself,

“Why didn’t they script this, it would be so much easier.”

After thinking about it for a while it all makes sense now. It seems that I had the shell script bug, everything must be done in the shell! In reality while the shell is great and all, it is not without its flaws. There are somethings the shell is great at and should be used for, then there others it shouldn’t.

Don’t get me wrong, I like to script as much as the next guy, but sometimes I think people get lost in its simplicity. Some people use it for everything without fail. Perhaps this is because they don’t know otherwise, or maybe because they too have the shell script bug.

There are many reasons to use the shell and I’m not against using it by any means. This is simply a list of when it may not be suitable to whip out the shell and start scripting. If there is any I missed, please add them in the comments and they may eventually make it into a revised post. I’ll do the same if I come up with any more. Onto the list!

Distribution / Portability – Ever try to distribute a script? Well, most of the time its not a problem, but sometimes you’ll get bit in the ass. Not all systems are created equal. Some have missing packages, or something doesn’t work the EXACT same way.

Simplicity – Sometimes bash is elegant. Well, it depends on your definition I guess. Some argue that scripting is simple, where as others that have to support or maintain it will be ready to cut you. I know I’m sharpening my shanks right now for some revenge. Seriously though, choose a language that makes it easy to K.I.S.S (keep it simple, stupid.)

Performance – Lets kick in the after burners. This is one I don’t have much experience in although I should probably look into it. The shell is sort of like a glider, it gets the jobs done, but I wouldn’t want to race it against a jet or anything. If you’re considering scripting, just time the process to make sure it meets your performance needs. Most of the time, if it is for you, you’ll be fine right? I mean you’ve got all of the time in the world and can wait overnight if you have to. I’d rather not, but have been known to wait on a slow script out of laziness.

Maintenance – Nightmare code. Dependency Hell. Some may have seen the t-shirt or heard the phrase,

“Programming is like sex; one mistake, and you’ll support it forever”

Yea scripting this is sort of like that, except you can always abandon and upgrade your scripts :)

Security – Keep it secure, there are many issues with security in shell scripts. We wont get into them now but if you wear a tinfoil hat when using a computer, you may not want to rely on shell scripts to do your top secret stuff.

sl the BOFH’s revenge for bad typists

Filed under: Linux Software — TheLinuxBlog.com at 9:57 am on Wednesday, November 19, 2008

If you don’t know what BOFH is, then lets try wikipedia. This morning in my feed reader from tips4linux.com was an article that “makes you pay attention.”

Basically, the article software package they were recommending today is sl. I couldn’t resist commenting on this. There are many times that I am stuck over a slow SSH session, all I need is the server admin, or BOFH coming along, installing sl and making my life a pain.

So, I installed it on my desktop. What an excellent piece of software. If you run Fedora its in the yum repos and you should give it a shot. Now, all I have to do is symlink this to other useful binaries that I commonly mistype, don’t have installed and for good operator measures, some that I do.

Its too bad that I couldn’t run this through wall, but I guess I could run it as a cron. I think it should have a config file so that you could work it a bit more. Perhaps as it steams through make the smoke spell a message. Any way, thats my ranting and rambling over for the morning. Now to yum remove.