Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What's your rationale for when to write a Bash script and when to use a more powerful scripting language (Python, Perl, Ruby, ...)?

I'm finding that very simple scripts are nicer with Bash, but many of those get quite fancy over time, and it never seems like a good idea to rewrite the whole thing. That's why I'm leaning towards always using Python for all scripting.

But since Bash seems to be the the lingua franca of Linux scripting, is that something a responsible system administrator would do?

share|improve this question

closed as not constructive by Tim Brigham, mulaz, Michael Hampton, Iain Nov 13 '12 at 16:56

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

This isn't really a technical question, but more of an opinion. You should use what you're comfortable with and it doesn't hurt to have experience with more than one scripting language. Each have their place & strengths/weaknesses. You should rephrase your post into more of a question.. "I want to do <this>, is this the best language/way to go about accomplishing <this>?" – bmurtagh Nov 13 '12 at 14:35

The answer on this always comes down to 'use what you know'. Depending on the purpose I regularly script in over half a dozen different languages. Most of the folks here will likely say the same.

share|improve this answer
+1 People spend a lot of time contemplating this non-problem from a technical standpoint. – msanford Nov 13 '12 at 14:48

Some tools/environments may be marginally better adapted to certain tasks than others, but when it comes to distinguishing between bash, python, perl and ruby (and similar) for administrative scripting, you should consider (if not favour) the human factors:

  1. Is maintainable? (You touched on this in your question.)
  2. Is it usable by other people within your organization? If you're (somehow) the only admin in your company who knows any python, it probably isn't be the right language to use, even if it makes shorter or more efficient scripts than the equivalent bash.

If the environments are equally available on your systems, and if many languages fit the bill, choose the one you're most comfortable with. Why? It will shorten development time, facilitate debugging, increase maintainability and at least not reduce institutional usability.

My subjective preference is for bash as well, but that doesn't matter: it's only my choice because I'm comfortable with it (say, I know how to manipulate iptables without looking up documentation).

share|improve this answer

Also, use the right tool for the job. Does your problem require more flexible data structures than bash provides?

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.