ADSM-L

Re: TSM Reporting..

2002-03-01 00:20:32
Subject: Re: TSM Reporting..
From: "Seay, Paul" <seay_pd AT NAPTHEON DOT COM>
Date: Fri, 1 Mar 2002 00:16:11 -0500
You can also specify a macro file on the server or your desktop as input to
the dsmadmc command with the pipe > command on the select or whatever
command.  The beauty of the macro xxxxxx call is that it can do a lot of
things and anyone can execute it.  Scripts require that you be a system
administrator regardless of what is in them.

A macro can also be scheduled to run off the server.

dsmadmc -id=admin -pass=<passwd> -outfile=report.txt macro
/input/blah.blah.txt

Contents of the /input/blah.blah.txt

select blah from blah where blah
Select blah-d-blah from blah-d-blah where blah-d-blah
Select %1 from %2 where %3 = %4

Macros support parameter input.  You can quote a string of stuff as one
parameter too.

I have written the generalized perl script below that does dsmadmc commands
that calls the system service also attached.

Tsmmacro.pl
#!/usr/bin/perl
# TSM Macro Execution utility.
#
# Invocation:
#    tsmcover.pl
#
# Required Options:
#
#                    [input file containing dsmadmc commands to execute]
#
#                    [output from dsmadmc file prefix] (optional)
#                      used as prefix with the contents of the suffix file
and '_'
#                      to create an output file name
#                    [suffix file] (optional)
#                      used to specify a file containing a suffix for the
output file
#
#                    This runs the file of dsmadmc commands contained in the
input file.
#                     An output file can be specified with our without a
suffix file.  The
#                     Output file can be specified in double quotes with a
leading pipe
#                     (>) which will cause an append.
#
# Fetch the arguements into a list
#
@list = @ARGV;
$numargs = scalar(@list);
#
# get the macro input file name, output file prefix (optional), output file
suffix
# (optional) specified on the command line.
#
$macroandparms = $list[0];
$filearg2 = $list[1];
$suffixfile = $list[2];
split(/ /,$macroandparms);
$filearg1num = scalar(@_);
$filearg1 = $_[0];
$macroparms = join(' ',@_[1 .. $filearg1num]);
print ($filearg1, "\n");
print ($macroparms, "\n");
#
# Execute the macro function contained in the file requested
# Create output file if specified
#
if (!-e$filearg1)                                     # make sure input file
exists
   {print "Bad input file name: ", $filearg1, "\n";
    die;
    }
$outfile = "Not Specified";
if ($numargs > 1)                                     # output file
specified?
   {$outfile = $filearg2;
    if ($numargs > 2)                                 # suffix file
specified?
       {$suffix = suffixread ($suffixfile);           # retrieve the suffix
        $outfile = $filearg2."_".$suffix;             # create output file
name with suffix
        }
    $outfile = "\>".$outfile;                         # add the pipe to the
command
    }
print "Output File is: ", $outfile, "\n";
if ($outfile eq "Not Specified")                      # clean up for command
   {$outfile = "";
    }
$command = "dsmadmc.bat ".'"'.$macroandparms.'"'.$outfile;
system($command);                                     # call the dsmadmc
interface
$exit_value = $_ >> 8;                                # shift to get the
return code
print ("tsmmacro return code: ", $exit_value, "\n");
exit($exit_value);
#
# Read Suffix File Subroutine and return
#
sub suffixread
   {my $suffixvalue;                                  # create local
variables
    my $suffixin;
    @parms = @_;                                      # get the file handle
    $suffixin = $parms[0];
    if (open (suffixfilein,"<",$suffixin))            # read the suffix
       {read suffixfilein, $suffixvalue, 40;
        close suffixfilein;
        return $suffixvalue;                          # return the suffix in
the function
        }
    else
       {print "Bad suffix File: ", $suffixin, "\n";
        return ""
        }
    };

Dsmadmc.bat is this on Windows, different on UNIX, have not written that one
yet, but the perl script should be platform independent.  I separated the
platform dependent stuff out.

@echo off
set macroin = %~f1
set rc = 99
pushd \"program files"\tivoli\tsm\baclient\
dsmadmc -id=userid -password=password -displaymode=table macro %macroin %
set rc = %errorlevel%
popd
echo Return Code from dsmadmc %rc %
set errorlevel = %rc %


<Prev in Thread] Current Thread [Next in Thread>