HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
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);	
	}