#!/h/COE/Comp/PERL5/bin/perl -T -I/h/COE/lib -w
use strict;
use Coe;
my $VERSION="1.1.4.1";
my $PRGM="COEFindSeg";
my $arg1;
my $file="";
my $flag="false";
my $flagclass=0;
my $segflag="false";
my $i=0;
my $path="";
my $ret;
my $seginfo="";
my $segname="";
my $segpath="";
my $segver="";
my $thisfile="";
my @class;
my @d;
my @date;
my @disk;
my @n;
my @segname;
my @segpath;
my @segtype;
my @t;
my @v;
my @version;
my @SEG;
# SEG[0]=dummy field for sort
# SEG[1]=segname
# SEG[2]=segtype
# SEG[3]=segpath
# SEG[4]=version
# SEG[5]=install date
# SEG[6]=patches
# SEG[7]=classification
sub openFile;
sub readFile;
sub getCoeHome;
sub getCoeAcct;
sub getCoeApps;
sub getCoeCots;
sub getCoeComp;
sub sortByField;
while (@ARGV > 0 ){
$arg1=shift;
$arg1=cleanString($arg1,4);
if ("$arg1" eq "-h") {
useage;
exit 0;
} elsif ("$arg1" eq "-H") {
coeMan("COE_HOME/docs/man/$PRGM");
exit 0;
} elsif ("$arg1" eq "-V") {
print "VERSION: $VERSION\n";
exit 0;
} else {
$segname="$arg1";
}
}
#my @SEGPATH=("/h", "/h/COTS", "/h/AcctGrps", "/h/COE/Comp") ;
my @SEGPATH=(getCoeApps, getCoeCots, getCoeAcct, getCoeComp, getCoeHome) ;
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# Standard Output
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# The IP Address of this machine is :
# The Host name of this machine:
# The number of installed segments on this machine is :
# SegName:Type:SegDir:Version:Date:[Patches]
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# COE 3.1 Output
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
# output header -- style COE 3.1
# :
#
# index : segment_name : segment_type : home_directory :
# segment_version : date_of_installation : patches
# --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----|
foreach (@SEGPATH) {
$path = coeFileConv("$_");
$file = coeFileConv("$segname");
#opendir DIR, "$path/$file" ||
#die "$0: cannot open dir $path/$file: $_\n";
#while ($file = readdir DIR) {
#if ("$file" !~ /^\./) {
$thisfile = "$path/$file/SegDescrip/Installed";
$thisfile = coeFileConv($thisfile);
if (-e "$thisfile") {
#my $FILE = readFile("$thisfile");
#while (<$FILE>) {
open FILE, "$thisfile";
while () {
if ("$_" ne "not installed") {
# - inititialize record
$SEG[0]="";
$SEG[1]="";
$SEG[2]="";
$SEG[3]="";
$SEG[4]="";
$SEG[5]="";
$SEG[6]="";
$SEG[7]="";
# get SegName and SegType
$SEG[3]=coeFileConv("$path");
$segname=coeFileConv("$path/$file/SegDescrip/SegName");
my $SEGNAME=readFile("$segname");
while (<$SEGNAME>) {
if (/\$NAME/) {
@n=split(":");
chomp($n[1]);
$SEG[1]=$n[1];
} elsif (/\$TYPE/) {
@t=split(":");
chomp($t[1]);
$SEG[2]=$t[1];
}
}
close $SEGNAME;
}
}
}
#}
closedir DIR;
}
if ("$SEG[1]" ne "" ) {
print "$SEG[3] : $SEG[1] : $segname : $SEG[2] : \n";
exit 0;
} else {
print "Not Found\n";
exit 1;
}