Friday, December 4, 2009

Automate *ANY* Interface from a Command Line

Given that this is the first post of the blog Autogration, I thought it would be worthwhile to describe an approach that will allow *ANY* interface to be automated and subsequently integrated with a  job stream.  There are a myriad of legacy interfaces that either have no ability to be automated which requires a human to interact with the system or if there is a command line interface, it does not provide the entire feature set required to automate the task at hand.  To over come this, there is the completely free and very light “AutoIt Script” product.   Some highlights include:


* Free download  at: http://www.autoitscript.com/autoit3/
* Very simple Basic like scripting in plain text
* Ability to compile stand-alone EXEs with  full digital signatures


Parameterize the scripts and execute the Windows automations as well as pass in the appropriate parameters to execute the specific reports you want to run.  Here is an example with NOTEPAD.EXE.


SYNTAX: <<script name.exe>>  << # of Params>>  <<Param1>>  <<Param2>>  <<Param3>> <<etc>>


$CmdLine[0] is number of parameters
$CmdLine[1] is param 1 (after the script name)
$CmdLine[2] is param 2 etc


EXAMPLE: RUN_REPORTS_NOW.EXE reports Vermont Cola


Note: AutoIt Scripts can be easily compiled with full digital signatures


Here is an example script:


Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send($CmdLine[2])
Send("{ENTER}")
Send("{ENTER}")
Send($CmdLine[3])
WinClose("Untitled - Notepad")
WinWaitActive("Notepad","Do you want to save")
send("!y")
WinWaitActive("Save As")
Send($CmdLine[1] & ".txt")
send("!s")


Here is the result:


Auto_script_example


In summary, the above is fully automatable with only a few lines of code and with the complete ability to run from the command line.  Now I am ready to automate the download and streaming of my own personal BBC podcast off of live updates from my XM Radio which is far superior and relevant news versus what they offer as Podcast or their website.

No comments:

Post a Comment