Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
    
This is a third party software winautomation.com –  PradeepGB Nov 16 '10 at 10:50
3  
As you can tell by the variety of answers below, the best solution depends on exactly what you want to accomplish and in what environment. –  Mark C Nov 16 '10 at 14:29
    
@Mark - I appreciate that but I'm ideally looking to learn one thing which has as generic an application as possible. –  Jon Hopkins Nov 17 '10 at 12:17
    
If you want to do everything, I suppose you will need at least 2-3 programs. Linux, Windows, MacOS? Code, filesystem, application macros? –  Mark C Nov 19 '10 at 0:57
add comment

closed as not constructive by MichaelT, Walter, Jim G., jimwise, Glenn Nelson Feb 1 '13 at 18:02

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

up vote 24 down vote accepted

Python

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.

share|improve this answer
    
That's the beauty. Thinking of "scripting" and "programming" languages as totally different animals is pretty much obsolete when there's Python. –  Joonas Pulakka Nov 16 '10 at 11:25
    
Ish, one of the key things in powershell is the pipelining - not sure how feasible that is in python (generically at least) –  Murph Nov 16 '10 at 12:17
    
+1, Python gets my vote as the best all around multi purpose scripting language. –  Josh K Nov 16 '10 at 12:51
    
+1 Same here, python works on most if not all platforms and is really the better "scripting" language for hacking some code together. –  Georges Nov 16 '10 at 13:30
1  
xkcd.com/353 –  Will Dec 31 '10 at 15:36
show 5 more comments

Powershell

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.

share|improve this answer
4  
Could the bright spark who downvoted without commenting please explain themselves? Thanks. –  Murph Nov 16 '10 at 14:09
add comment

Autoit is unbeatable. It's a tool with a language.

  • Easy to learn BASIC-like syntax
  • Simulate keystrokes and mouse movements
  • Manipulate windows and processes
  • Interact with all standard windows controls
  • Scripts can be compiled into standalone executables
  • Create Graphical User Interfaces (GUIs)
  • COM support
  • Regular expressions
  • Directly call external DLL and Windows API functions
  • Scriptable RunAs functions
  • Detailed helpfile and large community-based support forums
  • Compatible with Windows 2000 / XP / 2003 / Vista / 2008 / Windows 7 / 2008 R2
  • Unicode and x64 support
  • Digitally signed for peace of mind
  • Works with Windows Vista's User Account Control (UAC)
share|improve this answer
add comment

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.

share|improve this answer
add comment

For some tasks, Actions might be a good fit.

It has a sort-of flowcharting process, where you can add actions to be run sequentially. New actions can be written in java.

Disclaimer: I've yet to use it.

share|improve this answer
add comment

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.

share|improve this answer
add comment

A modern unix shell. E.g. bash.

share|improve this answer
    
Assuming of course that you're running in an enviroment that natively supports it (or that you count powershell as equivalent to a modern unix shell (-:) –  Murph Nov 16 '10 at 16:41
add comment

Python is great for this and has a larger install base, and Ruby is not any better except it has Why's Poignant Guide to Ruby. Seriously, cartoon foxes.

share|improve this answer
add comment

AutoHotKey

AutoHotkey is a free, open-source utility for Windows. With it, you can:

  1. Automate almost anything by sending keystrokes and mouse clicks.
  2. You can write a mouse or keyboard macro by hand or use the macro recorder.
  3. Create hotkeys for keyboard, joystick, and mouse. Virtually any key, button, or combination can become a hotkey.
  4. Expand abbreviations as you type them. For example, typing "btw" can automatically produce "by the way".
  5. Create custom data-entry forms, user interfaces, and menu bars. See GUI for details.
  6. Remap keys and buttons on your keyboard, joystick, and mouse.
  7. Respond to signals from hand-held remote controls via the WinLIRC client script.
  8. Run existing AutoIt v2 scripts and enhance them with new capabilities.
  9. Convert any script into an EXE file that can be run on computers that don't have AutoHotkey installed.

http://www.autohotkey.com

I've saved several companies a large sum of money by using this tool.

share|improve this answer
add comment

Perl

Perl is pretty much my definition of quick and dirty.

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.

share|improve this answer
3  
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 Hopkins Nov 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 Jackson Nov 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 Hopkins Nov 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 Nathan Nov 16 '10 at 16:32
add comment
  • The GUI guys in my organization like TestComplete for automation in Windows.
  • For CLI scripting, about 90% Perl and 10% Bash

I've been working on rolling together some Common Lisp routines to help with scripting, but it's not as easily native to that task as Perl.

share|improve this answer
add comment

For windows I highly recommend AutoIt (http://autoitscript.com). Make sure to install the Scite package from the downloads section.

http://autoitscript.com/forum is a great resource for getting help and finding UDF's function to include in scripts.

AutoIt is able to control application windows and controls allowing you automate just about anything. It also requires no dependencies after you compile you executable.

share|improve this answer
add comment

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

Languages and usage domain

AutoIT - Windows based GUI Automation Bash - Unix based automation mostly involves system interaction Perl - Data processing automation with less system interaction Expect - Character based interactive requirements. (which cannot be solved by Perl, Bash) VBS - Windows based scripting

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.

share|improve this answer
add comment

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