| Front Page | News Headlines | Technical Headlines | Planning Features | Advanced Search |
Epic Systems Sponsor Message

January 2002

Get the most out of your Robelle Tools

Perl Extension for Suprtool

By Bob Green

Ken Hirsch has created a Perl extension, MPE::Suprtool, which allows you to easily call Suprtool from Perl and pass it commands dynamically. You must, of course, already have Suprtool installed. This module is somewhat easier than creating a Suprtool script file, running Suprtool and then reading JCWs to figure out if it worked. You can download the module at

invent3k.external.hp.com/~MGR.HIRSCH/MPE-Suprtool-0.5.tar.gz

And read more about it at: invent3k.external.hp.com/ ~MGR.HIRSCH/Suprtool.html

To install the Suprtool extension, you also need the gcc compiler tools. Ken Hirsch has instructions for how to install his packages at invent3k.external.hp.com/ ~MGR.HIRSCH/perlinst.html

From Ken’s documentation file, here is a sample Suprtool task in Perl and some explanation of the functions provided:

use MPE::Suprtool;
chdir “/$ENV{HPACCOUNT}/PUB” or die “Cannot cd to PUB: $!\n”;
# May be necessary to chdir to an MPE group
# (depending on Suprtool version)
my $supr = MPE::Suprtool->new
or die “Cannot run Suprtool\n”;
my $account = 518;
$supr->cmd(
“bas ordrdb,5,password”,
“chain order-detail,account=$account”,
“extr order-num, account, invoice”,
“output ordlist,ascii”,
“purge ordlist”,
“exit”) or die “Error on Suprtool comand ‘“ . $supr->lastcmd .
“‘, status = “ . $supr->status . “\n”;
print “I wrote “, $supr->count, “ records.”;

The extension provides three functions: new, cmd and lastcmd.

new ( [args] ) — Creates a new Suprtool object. new optionally takes arguments; these arguments are in key-value pairs and define the execution priority and the XL location of the Suprtool2 subroutine. For example:

my $supr = MPE::Suprtool->new( printstate => ‘AL’, pri => ‘CS’)
or die “Cannot run Suprtool\n”;

cmd( @list ) — cmd submits a command or list of commands to Suprtool. This is a list of strings, which can be an array variable, string literals, a list of scalar string variables, or just about any combination. The normal Perl rules apply, so if you want to say OUTPUT $NULL you’ll need to use single quotes ‘OUTPUT $NULL’ or escape the $ in double quotes: ``OUTPUT \$NULL’’

Of course, sometimes you want to interpolate a variable. The commands are only executed when there’s an ``EXIT’’ in a string by itself. Each command string can be up to 256 characters long. You can combine commands in one string by separating them with a semicolon. The following all have the same effect:

$supr->cmd(“INPUT FILE1; KEY 1,4; OUTPUT FILE2”, “EXIT”);
OR
$supr->cmd(“INPUT FILE1”, “KEY 1,4”);
$supr->cmd(“OUTPUT FILE2”, “EXIT”);
OR
$supr->cmd(“INPUT FILE1”);
$supr->cmd(“KEY 1,4”);
$supr->cmd(“OUTPUT FILE2”);
$supr->cmd(“EXIT”);
OR
@a = (“KEY 1,4”, “OUTPUT FILE2”);
$supr->cmd(“INPUT FILE1”, @a, “EXIT”);
and so on.

Lastcmd — The last command executed. If cmd is passed a list, it will stop on any command giving an error. Some syntax errors will be caught on the command containing the error, but most errors will only get caught on the ‘EXIT’ command, so this is of limited utility.

So now you have a great excuse to install Perl on your HP 3000 and learn it – you can use it to execute Suprtool tasks! 


Copyright The 3000 NewsWire. All rights reserved.