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.





Random Man Pages:
pam
siliconmotion
syslog
variables

4 Comments »

Comment by kaleb

December 2, 2009 @ 11:27 am

ahh Owen once again you make me laugh sometimes you write the best articles. one thing i have to say about this subject, keep in mind I love scripting as well and don’t bash it in any way (no pun intended), is that maybe you should not script something that already has a equivalent program (don’t do what has been done already). Don’t just script because you can. such as don’t rewrite the way a screenshot is taken scrot has that down pat. the way I think of scripting is that you should script when you have a long drawn out process of stuff to do and you don’t want to sit and do it yourself good example is renaming a bunch of files, everybody has there experiance with this nonsese. or how about ripping a CD. i know what your saying “but Kaleb that has an equivalent app” I know but in this case the app may not do you justice in the means of quality or the naming sequence for the tracks. anyways great article owen and I’m out.

Comment by Web2Linux

December 3, 2009 @ 1:48 pm

Nice posting. Really liked it :)

Comment by Jonathon

December 17, 2009 @ 7:27 pm

Nice entry. I liked it.

Comment by Bruce

May 19, 2010 @ 11:39 am

ahh Owen once again you make me laugh sometimes you write the best articles. one thing i have to say about this subject, keep in mind I love scripting as well and don’t bash it in any way (no pun intended), is that maybe you should not script something that already has a equivalent program (don’t do what has been done already). Don’t just script because you can. such as don’t rewrite the way a screenshot is taken scrot has that down pat. the way I think of scripting is that you should script when you have a long drawn out process of stuff to do and you don’t want to sit and do it yourself good example is renaming a bunch of files, everybody has there experiance with this nonsese. or how about ripping a CD. i know what your saying “but Kaleb that has an equivalent app” I know but in this case the app may not do you justice in the means of quality or the naming sequence for the tracks. anyways great article owen and I’m out.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>