We all have tasks that come up from time to time that we think we'd be better off scripting or automating than doing manually.

Obviously some tools or languages are better for this than others - no-one (in their right mind) is doing a one off job of cross referencing a bunch of text lists their PM has just given them in assembler for instance.

What one tool or language would you recommend for the sort of general quick and dirty jobs you get asked to do where time (rather than elegance) is of the essence?

Background: I'm a former programmer, now development manager PM, looking to learn a new language for fun. If I'm going to learn something for fun I'd like it to be useful and this sort of use case is the most likely to come up.

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

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.

13 Answers
13

The obvious answer (and with good reason) is Python. Its a solid language, available cross platform. As its dynamic you can run it interactively which is great for lashing stuff together and it has a fairly large selection of libraries so its a general purpose language so can be applied to most problems.

This is less generic than Python - but if you exist in a Windows environment then its probably that its going to be more useful.

Its more shell/script like than Python (because that's what it is) but it can hook into the .NET framework which gives you a quite extraordinary depth of capability. It also has broad community support.

Microsoft have been busy adding powershell to their server products (hence the "more useful") and have introduced remoting to allow you to run scripts there from your console here.

Perl is infinitely flexible which is a strength and weakness. It doesn't force structure on you, but it's there if you want it. It has libraries for everything. It's been used extensively for 20 years; there's tons of code out there to work with.

I thought Perl would come up a lot sooner. I'd considered Perl as I've got passing exposure to it but it just makes me want to scrub my eyes with bleach every time I read it. $=;$_=\%!; $_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=($!=~/(.)(.).(.)(.)(.)(.‌​)..(.)(.)(.)..(.).......)/,$"),$=++;$.++;$.++;$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%‌​[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++;$,++;$^|=$";$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}‌​$%[$?]$;$\$"$^$~$*.>&$= (that's actual Perl - admittedly wilfully bad Perl - for those who don't read it).
–
Jon HopkinsNov 16 '10 at 16:26

1

@Jon I mostly added it because it wasn't here. I agree it can get pretty messy, it doesn't enforce any discipline on you, you have to bring your own. Considering the vast majority of the time it's used for quick and dirty scripting, you get what you see.
–
Steve JacksonNov 16 '10 at 16:29

2

Yep - and Perl shouldn't be blamed for the messiness, that's down to the programmer. Besides, if your programming language only lets you write good code, you get no credit for doing so...
–
Jon HopkinsNov 16 '10 at 16:30

1

I think Perl is the best scripting language now extant - it's not opinionated and lets do what you need to do without griping.
–
Paul NathanNov 16 '10 at 16:32

elisp, if you have seen the wealth of tasks it is used in order to accomplish through its underlying platform Emacs. Emacs can eschew all the functionality of a full blown window manager, IDE, Office, browser, email client, chat client, shell, filesystem explorer, and more. Most of it is accomplished through elisp programs.

For complex automation you may want to use Robot Framework. The framework is mostly aimed at automated testing but can also be used for general automation.

You can easily write your own libraries in Python and there are a number of pre-existing ones (selenium, AutoIt, telnet, ssh, swing, etc) which allow you to drive all sorts of things which is very powerful if you're in a mixed enviroment.

It is keyword driven so you can create new keywords and hence abstract away repetitive tasks and even has an IDE which is being actively developed that allows for some simple refactorings.

I had the same problem of using multiple languages for different set of automation.
I'm a senior consultant for an IT Service company in India. Every time I consult a different

language for the purpose, I had tough time justifying it to the management.
I even discussed with my friends (as casual talk) about developing a unified language that
address all the automation needs and still cross-platform. If one is available, then it may

change the scripting world. As far as I know, the mapping we usually use goes

Any Automation always accompanies with one or more remote invocation for either information retrieval or result publishing. Here are the different list addressing major OS.

Remote Script Invocation (tools)

Windows -> Windows

psexec, Powershell

Windows -> Unix

plink, Quest Plink -> SSH Server

Unix -> Unix

SSH client -> SSH Server

Unix -> Windows

winexe, wmic -> WMI Agent
check_nrpe -> NRPE_NT Agent

In the above list, you can easily make out that no language can replace another in feature set. We've to live with those until we have one universal OS and universal standard of communication protocols and APIs.