Writing Scripts

It is intended to be easy to write scripts for AAI). Without knowing too much about how AAI works, one should be able to write a script that gets some basic information from AAI or automates work with it.

For example, to list all the jobstreams defined in AAI, create a file called my_script.py with the following contents:

from jaws import *
login()
print 'jobstreams:', jobstreams()

Save the file, and run it using one of the following commands:

  • run.bat my_script.py

  • run.pl my_script.py.

You will see some status information, followed by a list of jobstream names, surrounded by square brackets, [ ].

The first line tells the interpreter where to find the commands for AAI. The second line, "login()", establishes a connection to the server and prints a message about the status of AAI. Each script will begin with these two lines. The last line in this example prints the names of all jobstreams.

This script assumes you are running it on the same machine that is running the AAI Server. If not, you need to supply a host name for the AAI Server. Also, you may need to specify an AAI user and password, unless you are using the default user, "admin," and default password. The login command, like many of the commands available in the AAI Batch interface, can accept optional parameters in any order:

login(host='aai.mycompany.com', user='steve', password='elmo')

Note: You can run the scripts elsewhere by simply copying the contents of the "batch" directory to another machine which has network access to the server.

This section includes the following pages: