Using the ILux Server API
Using the API from a Script
Scripts are basically a means of automating the interaction with the ILux server over Telnet. The process involves connecting to ILux and sending
commands over the Telnet interface, then disconnecting when processing is complete. Scripts can vary from extremely simple to quite complex, and can be written in any scripting language.
The example used here is written in Perl, which is available on both NT and Unix platforms. The script (iluxscript.pl) reads a user-defined file containing ILux API commands, substitutes any parameter variables specified on the command line, and sends the commands to the ILux server.
The command line takes the form:
perl path\iluxscript.pl path\commandfile attribute="value"
attribute2="value" ...
path\ is the fully qualified path to the script or your command
file.
The 'attribute' can be any word you want to use. There are no predefined
attributes. The "value" is the string you want substituted for any
occurrence of #attribute# in the command file.
For example, let's assume you enter the following command:
perl d:\bin\iluxscript.pl d:\bin\cmds.txt foldername="Barney" reportname="Hits
Report" filter="Barney Only" email="barney@pbs.org" domain="pbs"
And the command file d:\bin\cmds.txt contains:
verbose
port=1600
server=host1.yourdomain.com
CREATE FILTER '#filter#' Domain is '#domain#'
CREATE FOLDER '#foldername#'
CREATE REPORT '#foldername#/#reportname#' Filter = '#filter#'
ADD ANALYSISOBJECT 'Top 10 Hits' TO REPORT '#foldername#/#reportname#'
SCHEDULE REPORT '#foldername#/#reportname#' Period='Weekly', MailTo='#email#'
QUIT
iluxscript.pl would translate the command file and send the following
series of commands to the specified ILux server (in this case
host1.yourdomain.com):
CREATE FILTER 'Barney Only' Domain is 'pbs'
CREATE FOLDER 'Barney'
CREATE REPORT 'Barney/Hits Report' Filter = 'Barney Only'
ADD ANALYSISOBJECT 'Top 10 Hits' TO REPORT 'Barney/Hits Report'
SCHEDULE REPORT 'Barney/Hits Report' Period='Weekly',
MailTo='barney@pbs.org'
QUIT
The first three lines in the command file (cmds.txt) are not ILux API commands, but commands used to control operation of the script. All are optional. 'verbose' tells the script to use verbose logging mode. 'port=' allows you to override the default port of 1600 if ILux has been installed to use a port other than 1600. And 'server=' allows you to specify the name of the ILux server.
Note that if you don't want to actually send the commands to the server,
but just want to test out translation of the command file, just specify
server= (no server name) or omit the server= command from the command file. Translated output will be written to the logfile
"scriptlog(datestamp).txt" but not sent to the server. The logfile is written to the current directory.
Additional uses:
This script could be called from a BAT file (or shell script) to
minimize command line typing. For example, instead of typing the
command:
perl d:\bin\iluxscript.pl d:\bin\cmds.txt foldername="Barney" reportname="Hits
Report" filter="Barney Only" email="barney@pbs.org" domain="pbs"
Place the following in a BAT file called say, stdrept.bat:
perl d:\bin\iluxscript.pl d:\bin\cmds.txt foldername="%1" reportname="%2"
filter="%3" email="%4" domain="%5"
Then from the command line you could enter:
stdrep "Barney" "Hits Report" "Barney Only" "barney@pbs.org" "pbs"
Note that when using this technique, the parameters on the BAT command become positional. That is they must be in the same sequence as those specified on the iluxscript.pl command line.
The source code for this Perl script is available here.
API Overview
Related Topics
|