#  $Header: emagent/sysman/admin/scripts/pidfile /st_emagent_10.2.0.1.0/1 2009/03/10 05:32:11 pnayak Exp $
#
#  Copyright (c) Oracle Corporation 2001. All Rights Reserved.
#
#    NAME
#      pidfile - <one-line expansion of the name>
#
#    DESCRIPTION
#      Verify that a pid file is accurate.
#      Options:
#        <pidfile> The file that has the pid in it.
#        <process> The name of the process that should be in that slot.
#
#    NOTES
#      <other useful comments, qualifications, etc.>
#
#    MODIFIED   (MM/DD/YY)
#    xxu         06/25/02 - remove /usr/local/bin/perl
# 3 Ash: Changed argument order.
# 2 Ash: Updated description for CGI index generation.
# 1 Ash: Initial version.
#

$ENV{PATH} = "/bin:/usr/bin:/usr/sbin:/usr/ucb";

my $process = shift;
my $file = shift;

my $found = 0;

open FILE, "<$file" or die "Unable to read file. [$!]\n";
my $target_pid = <FILE>;
chomp $target_pid;


# Get list of procs.
$DATA = `ps -f -p $target_pid`;

if ( $DATA =~ m|[/\s]$process[\s]|) {
  print "em_result=$file=1|$target_name from $file was found.\n";
} else {
  print "em_result=$file=0|$target_name from $file was not found.\n";
}



