File: //var/opt/OV/bin/instrumentation/what.pl
###############################
#
# @(#)HP Operations Smart Plug-ins for Infrastructure 11.14.014 06/07/14
#
###############################
sub GetDataDir {
open (OVPATHEXE, "ovpath -datadir|") or die("unable to run ovpath binary: \n");
$out = <OVPATHEXE>;
close OVPATHEXE;
chomp $out;
$out = $out . '/';
return $out;
}
# To get the vesion of particular file
my $filename_passed = $ARGV[0];
$path=GetDataDir()."bin/instrumentation";
chdir($path) or die "Cant chdir to $path $!";
if ($^O ne "MSWin32")
{
if($filename_passed)
{
open (GREP,"egrep \"HP Operations Smart Plug-ins for Infrastructure|# Version|HP OMI Management Pack for Infrastructure\" $filename_passed |");
while (<GREP>)
{
chomp $_;
my $string = $_;
if( $string =~ /(\d+).(\d+).(\d+)(.+)/)
{
$version = $1.".".$2.".".$3."".$4;
}
if ($filename ne "what.pl")
{
$filename_passed .= " \t\t ".$version;
print "$filename_passed\n";
}
}
}
else
{
# egrep "HP Operations Smart Plug-ins for Infrastructure|# Version" *
open (GREP,"egrep \"HP Operations Smart Plug-ins for Infrastructure|# Version|HP OMI Management Pack for Infrastructure\" * |");
while (<GREP>)
{
chomp $_;
my ($filename,$string,$version) = split (/:/,$_);
if( $string =~ /(\d+).(\d+).(\d+)(.+)/)
{
$version = $1.".".$2.".".$3."".$4;
}
if ($filename !~ /^what*/)
{
$filename .= " \t\t ".$version;
print "$filename\n";
}
}
}
close (GREP);
}
else
{
if($filename_passed)
{
open (FINDSTR,"findstr /c:\"HP Operations Smart Plug-ins for Infrastructure\" $filename_passed |");
while (<FINDSTR>)
{
chomp $_;
my $string = $_;
if( $string =~ /(\d+).(\d+).(\d+)(.+)/)
{
$version = $1.".".$2.".".$3."\t".$4;
}
if ($filename ne "what.pl")
{
$filename_passed .= " \t\t ".$version;
print "$filename_passed\n";
}
}
open (FINDSTR,"findstr /c:\"# Version\" $filename_passed |");
while (<FINDSTR>)
{
chomp $_;
my $string = $_;
if( $string =~ /(\d+).(\d+).(\d+)(.+)/)
{
$version = $1.".".$2.".".$3."\t".$4;
}
if ($filename ne "what.pl")
{
$filename_passed .= " \t\t ".$version;
print "$filename_passed\n";
}
}
open (FINDSTR,"findstr /c:\"HP OMI Management Pack for Infrastructure\" $filename_passed |");
while (<FINDSTR>)
{
chomp $_;
my $string = $_;
if( $string =~ /(\d+).(\d+).(\d+)/)
{
$version = $1.".".$2.".".$3;
}
if ($filename ne "what.pl")
{
$filename_passed .= " \t\t ".$version;
print "$filename_passed\n";
}
}
}
else
{
open (FINDSTR,"findstr /c:\"HP Operations Smart Plug-ins for Infrastructure\" * |");
while (<FINDSTR>)
{
chomp $_;
my ($filename,$string,$version) = split (/:/,$_);
if( $string =~ /(\d+).(\d+).(\d+)(.+)/)
{
$version = $1.".".$2.".".$3."\t".$4;
}
if ($filename ne "what.pl")
{
$filename .= " \t\t ".$version;
print "$filename \n";
}
}
open (FINDSTR,"findstr /c:\"# Version\" * |");
while (<FINDSTR>)
{
chomp $_;
my ($filename,$string,$version) = split (/:/,$_);
if( $string =~ /(\d+).(\d+).(\d+)(.+)/)
{
$version = $1.".".$2.".".$3."\t".$4;
}
if ($filename ne "what.pl")
{
$filename .= " \t\t ".$version;
print "$filename \n";
}
}
open (FINDSTR,"findstr /c:\"HP OMI Management Pack for Infrastructure\" * |");
while (<FINDSTR>)
{
chomp $_;
my ($filename,$string,$version) = split (/:/,$_);
if( $string =~ /(\d+).(\d+).(\d+)/)
{
$version = $1.".".$2.".".$3;
}
if ($filename ne "what.pl")
{
$filename .= " \t\t ".$version;
print "$filename \n";
}
}
}
close (FINDSTR);
}