views:

237

answers:

5

Imagine that you need to develop and schedule an application/script to do the following:-

  • Reference one or more .net assemblies
  • Query the API, get some objects
  • for each object call another method in the API

What would you use?

In the past I have created small console applications that do the above, but it seems a bit clumsy and overkill.

I imagine something like PowerShell or IronPython might be a better fit.

Any recommendations?

+10  A: 

Absolutely PowerShell, that's exactly the sort of thing it's designed for.

Here's some useful resources to help you get started:

Ash
+2  A: 

The problem with application drivers is that they constantly break. Applications are constantly changing their external surface and this wreaks havoc on drivers. Therefore you constantly need to updated parts of the drivers. I find a non-compiled dynamic language is ideal for this as you can quickly make an update and kick off a task.

Powershell is a great technology for this. It is an amazingly flexible and really easy to pick up. It is a mix of compiled and dynamic code. So the more algorithm heavy portions of your driver can be any compiled language and the more fragile and frequently updated pieces can be script. They integrate seamlessly.

I'm an avid Powershell user and really don't have much experience with IronPython (hence my choice). IronPython could also have these features though so if you're more comfortable with that language it's where you should go.

JaredPar
+3  A: 

One of the advantages of PowerShell is that they've done a lot of work in the background to make things fit together easily, doing implicit type conversions etc to make the output of one program usable as the input to another. And since everything passes objects, you don't have to write text munging code to cobble things together.

I do prefer Python, however, when I'm writing a large amount of original code rather than relying heavily on libraries and gluing together components.

John D. Cook
A: 

Out of frustration with PowerShell I did look into IronPython. I think this is a good alternative to powershell, especially if you are a programmer. Even if you are an IT person, I think Windows command shell + IronPython is a good combination that will accomplish what you need in the .NET era (like what command shell + vbscript was fine for in the COM era).

DSO
+2  A: 

IronPython.

I trialled using both Powershell and IronPython for the above task and came to the conclusion that IronPython was the best fit (for me).

To be fair either Powershell or any DLR based language such as IronPython or IronRuby would suit the task and would be less overhead than looking after trivial console applications.

If all you are doing is consuming a .net library and doing some scripting then IronPython edges Powershell. If you want to utilise some sort of shell-type functionality or use existing CMDLETS then Powershell is a better choice.

IronPython, being a implementation of python, brings all the advantages of python for scripting such as being easy to learn, easy to read and quick to develop in.

Andrew Rimmer