[opencoe-developer] COEListSeg bug
Status: Alpha
Brought to you by:
rbroberg
From: Ron B. <ron...@ya...> - 2003-09-09 03:33:02
|
ran Open COE 1.1.4.0 recently. When I installed several segments on my computer. I found that the COEListSegs only listed 8 segments.The output on my computer was just like this: The IP Address of this machine is : 127.0.0.1 The Host name of this machine: localhost The number of installed segments of this machine is :8 0:ICEMail (Java Mail Client):Software:/h/ICEMAIL:3.5.0.0 : 080943:25 Sep 03: 1:JAMES (JAMES Mail Server):Software:/h/JAMES:2.0.2.0 : 080943:29 Sep 03: 2:JFTPCLI (Java FTP Client):Software:/h/JFTPCLI:0.8.4.0 : 080943:39 Sep 03: 3:Java DNS Server:SOFTWARE:/h/DNSJAVA:1.2.3.0 : 080943:23 Sep 03: 4:Jetty (Java Web/Servlet Server):Software:/h/JETTY:4.0.3.0 : 080943:38 Sep 03: 5:OpenCOE Developers Toolkit:Software:/h/COESDK:0.0.0.1 : 302232:27 Aug 03: 6:Testapp :SOFTWARE:/h/TESTAPP:1.0.0.0 : 302155:50 Aug 03: 7:XBrowser (Java Web Client):Software:/h/XBROWSER:4.2.0.0 : 080943:42 Sep 03: But I installed more than ten segments on my computer. So, I examined the code. At last, I found where is the problem. The statement "foreach (@SEG)" at line 207,213,226,248 only list the first dimension of the @SEG. The first dimension of array @SEG is 8, so only 8 elements will print.So I exchange the first dimension and second dimension of array @SEG, then COEListSegs output like this: The IP Address of this machine is : 127.0.0.1 The Host name of this machine: localhost The number of installed segments of this machine is :20 0:ICEMail (Java Mail Client):Software:/h/ICEMAIL:3.5.0.0 : 080943:25 Sep 03: 1:JAMES (JAMES Mail Server):Software:/h/JAMES:2.0.2.0 : 080943:29 Sep 03: 2:JFTPCLI (Java FTP Client):Software:/h/JFTPCLI:0.8.4.0 : 080943:39 Sep 03: 3:JFTPSVR (Java FTP Server):Software:/h/JFTPSVR:0.6.0.0 : 080943:40 Sep 03: 4:JH2N (Java Hosts to Name):Software:/h/JH2N:0.9.2.0 : 080943:40 Sep 03: 5:Java DNS Server:SOFTWARE:/h/DNSJAVA:1.2.3.0 : 080943:23 Sep 03: 6:Java2 Runtime Environment:COTS:/h/COE/Comp/JAVA2:1.4.0.1 : 292229:33 Aug 03: 7:Jetty (Java Web/Servlet Server):Software:/h/JETTY:4.0.3.0 : 080943:38 Sep 03: 8:OpenCOE Developers Toolkit:Software:/h/COESDK:0.0.0.1 : 302232:27 Aug 03: 9:Operating System Intefaces:Software:/h/COE/Comp/OS:1.1.3.1: 292229:34 Aug 03: 10:PERL5:SOFTWARE:/h/COE/Comp/PERL5:5.6.0.0 : 292229:34 Aug 03: 11:Security Admin:ACCOUNT GROUP:/h/AcctGrps/SecAdm:1.0.0.1: 292218:15 Aug 03: 12:Staff:ACCOUNT GROUP:/h/AcctGrps/Staff:1.0.0.1: 292218:17 Aug 03: 13:Staff:ACCOUNT GROUP:/h/COE/Comp/Staff:1.0.0.1: 292229:38 Aug 03: 14:System Admin:ACCOUNT GROUP:/h/AcctGrps/SysAdm:1.0.0.2: 292218:05 Aug 03: 15:System Admin:ACCOUNT GROUP:/h/COE/Comp/SysAdm:1.0.0.2: 292229:37 Aug 03: 16:Testapp :SOFTWARE:/h/TESTAPP:1.0.0.0 : 302155:50 Aug 03: 17:UAM (User and Application Manager):Software:/h/COE/Comp/UAM:1.1.3.1: 292229:35 Aug 03: 18:User Management API:Software:/h/COE/Comp/UserMgmt:1.1.3.2: 292229:35 Aug 03: 19:XBrowser (Java Web Client):Software:/h/XBROWSER:4.2.0.0 : 080943:42 Sep 03: The file that I have modified is attached in this mail. Sincerely hope you can check it. Thanks. <name withheld> Plain Text Attachment [ | Download File ] #!/h/COE/Comp/PERL5/bin/perl -T -I/h/COE/lib -w use strict; use Coe; my $VERSION="1.1.4.0"; my $PRGM="COEListSegs"; sub useage { print "Useage: COEListSegs [flags]\n"; } my $arg1; my $file=""; my $flag="false"; my $flag31=0; my $flagclass=0; my $flaginstaller=0; my $flagsortbyname=1; my $flagsortbytype=0; my $i=0; my $ipaddr="127.0.0.1"; my $hostname="localhost"; 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; } elsif ("$arg1" eq "-31") { $flag31=1; } elsif ("$arg1" eq "--installer") { $flaginstaller=1; } elsif ("$arg1" eq "-i") { $ipaddr=cleanString(shift,4); } elsif ("$arg1" eq "-n") { $hostname=cleanString(shift,4); } elsif ("$arg1" eq "-sn") { $flagsortbyname=1; } elsif ("$arg1" eq "-st") { $flagsortbytype=1; } else { coeMan("COE_HOME/docs/man/$PRGM"); exit -1; } } #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 : <address> # The Host name of this machine: <hostname> # The number of installed segments on this machine is : <number_segments> # SegName:Type:SegDir:Version:Date:[Patches] # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # COE 3.1 Output # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| # output header -- style COE 3.1 # <address>:<hostname> # <number_segments> # index : segment_name : segment_type : home_directory : # segment_version : date_of_installation : patches # --+----|----+----|----+----|----+----|----+----|----+----|----+----|----+----| $i=-1; foreach (@SEGPATH) { $path = coeFileConv("$_"); opendir DIR, "$path" || die "$0: cannot open dir $path: $_\n"; while ($file = readdir DIR) { if ("$file" !~ /^\./) { $thisfile = "$path/$file/SegDescrip/Installed"; $thisfile = coeFileConv($thisfile); if (-e "$thisfile") { my $FILE = readFile("$thisfile"); while (<$FILE>) { if ("$_" ne "not installed") { $i++; # - inititialize record $SEG[$i][0]=""; $SEG[$i][1]=""; $SEG[$i][2]=""; $SEG[$i][3]=""; $SEG[$i][4]=""; $SEG[$i][5]=""; $SEG[$i][6]=""; $SEG[$i][7]=""; # get Date chomp($_); $SEG[$i][5]=$_; # get SegName and SegType $SEG[$i][3]=coeFileConv("$path/$file"); $segname=coeFileConv("$path/$file/SegDescrip/SegName"); my $SEGNAME=readFile("$segname"); while (<$SEGNAME>) { if (/\$NAME/) { @n=split(":"); chomp($n[1]); $SEG[$i][1]=$n[1]; } elsif (/\$TYPE/) { @t=split(":"); chomp($t[1]); $SEG[$i][2]=$t[1]; } } close $SEGNAME; # get Version $segver=coeFileConv("$path/$file/SegDescrip/VERSION"); my $VERS=readFile("$segver"); while (<$VERS>) { if (! /^#/ && /^.*:/) { @v=split(":"); chomp$v[0]; $SEG[$i][4]=$v[0]; } } close $VERS; # get classification and disk size $SEG[$i][7]="UNCLASS"; $disk[$i]="0"; $seginfo=coeFileConv("$path/$file/SegDescrip/SegInfo"); my $SEGINFO=readFile("$seginfo"); while (<$SEGINFO>) { if (/\$DISK/) { @d=split(":"); chomp($d[1]); $disk[$i]=$d[1]; } elsif (/\[Classification]/) { $flagclass=1; } elsif ($flagclass == 1) { chomp($_); $SEG[$i][7]=$_; $flagclass=0; } } } } } } } closedir DIR; } if ($flagsortbytype == 1) { @SEG = sortByField 2, @SEG; } else { @SEG = sortByField 1, @SEG; } if ($flag31 == 1) { print "\n"; print "$ipaddr:$hostname\n"; print "$i\n"; print "\n"; $i=0; foreach (@SEG) { print "$i: $SEG[$i][1] : $SEG[$i][2] : $SEG[$i][3] : $SEG[$i][4] : $SEG[$i][5]\n"; $i++; } } elsif ($flaginstaller == 1 ) { $i=0; foreach (@SEG) { print "$SEG[$i][2] : $SEG[$i][1] : $SEG[$i][4] : $SEG[$i][7] : $disk[$i] : $SEG[$i][3] :\n"; $i++; } } else { print "\n"; print "The IP Address of this machine is : $ipaddr\n"; print "The Host name of this machine: $hostname\n"; print "The number of installed segments of this machine is :$i\n"; print "\n"; $i=0; foreach (@SEG) { if ($SEG[$i][1]) { print "$i:$SEG[$i][1]:$SEG[$i][2]:$SEG[$i][3]:$SEG[$i][4]: $SEG[$i][5]:\n"; $i++; } } } exit 0; # ============================================================================== sub sortByField { my ($field, @s)=@_; my @segs; my @segss; #$field=2; $i=0; foreach (@s) { if ($s[$i][$field]) { $segs[$i]="$s[$i][$field]\^$s[$i][1]\^$s[$i][2]\^$s[$i][3]\^$s[$i][4]\^$s[$i][5]\^$s[$i][6]\^$s[$i][7]"; $i++; } } @s = sort @segs; $i=0; foreach (@s) { @segs=split('\^'); $segss[$i][0]=$segs[0]; $segss[$i][1]=$segs[1]; $segss[$i][2]=$segs[2]; $segss[$i][3]=$segs[3]; $segss[$i][4]=$segs[4]; $segss[$i][5]=$segs[5]; $segss[$i][6]=$segs[6]; $segss[$i][7]=$segs[7]; $i++; } #$i=0; #foreach (@segss) { #print "$segss[1][$i] $segss[2][$i]\n"; #$i++; #} return @segss; } __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com |