Writing Scripts

You don't need to know AAI in depth to be able to write scripts that get some basic information from AAI or that automate basic AAI tasks. This topic shows you one basic script.

Example of a basic script to find all jobstreams

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.pl my_script.py.

  • run.bat my_script.py (Windows)

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.

Parameter considerations

The previous example shows a script based on certain assumptions. To use it in your environment, you might need to modify it, as follows:

  • The 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.

  • Unless you are using the default user, "admin," and default password, you need to specify an AAI user and 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: