#!/usr/sbin/rsct/perl5/bin/perl
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
#  
#  
# Licensed Materials - Property of IBM 
#  
# (C) COPYRIGHT International Business Machines Corp. 2000,2007 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
#
# @(#)28   1.4         src/rsct/cfg_access/gpfs/ct_read_machines_lst.perl, cfg.access, rsct_relgh, relghs001a 1/27/03 18:56:56
#
# Usage: ct_read_machines_lst [-l] <filename>
#   -l for the local data access
#
use Getopt::Std;

my %opts = ();
&getopts(':l',\%opts);
my $mmref=(defined($opts{l}) ? "norefresh" : "refresh");
my $filename="";

($dir,$progname) = $0 =~ /(.*\/)?(.*)/; # get basename of $0

#-------- functions -----------------------------------
# print_dbgmsg(list)
sub print_dbgmsg
{
  my @args = @_;
  if(!defined($ccal_log_inited)) {
        my $outfile = $ENV{"HA_CCAL_LOG"};
        $ccal_log_inited = 0;
        if(defined($outfile) && open(LOGOUT, ">>$outfile")) {
            $ccal_log_inited = 1;
            select LOGOUT;
            $| = 1; # unbuffered
            select STDOUT;
        }
  }
  if($ccal_log_inited) {
        my $dstr = scalar(localtime);
        my $msg = "$dstr $progname: " . join(" ", @args);
        print LOGOUT $msg, "\n" ;
  }
}

sub print_errmsg
{
   &print_dbgmsg(@_);
   print STDERR "# $progname: ", join(" ", @_), "\n";
}
#-----------------------------------------------------


# Get the arguments...
if ($#ARGV >= 0) {
    $filename = shift @ARGV;            # user specified resource
} else {
    print STDERR "#no file name\n";
    exit 1;
}

# return codes:
#   0 if successful
#   1 if there is an error
#   2 if <ct_read_machines.lst> not supported

$MMHA="/usr/lpp/mmfs/bin/mmha";
$MMHACMD="${MMHA} haGetMachineslst $filename $mmref"; 
&print_dbgmsg("$MMHACMD");
exec "$MMHACMD";
exit 1;
