1; sub trim { my $string = shift(@_); $string =~ s/\s//g; return $string; } sub TRACE { if ($debug) { open(LOG, ">>$tracefile"); print LOG localtime(time). " - "; print LOG @_; print LOG "\n"; close(LOG); } } sub getsgapid { my $emdhome = $_[0]; my $conn = $_[1]; TRACE("emdhome = ".$emdhome); TRACE("conn = ".$conn); $pidvalcmddir = $emdhome."/bin"; chdir($pidvalcmddir) || die "Cannot chdir $pidvalcmddir: $!"; if($NT) { open(BUFP, "nmcbufp ".$conn."|"); $pidval = ; close(BUFP); } else { open(BUFP, "./nmcbufp \'".$conn."\'|"); $pidval = ; close(BUFP); } TRACE("nmcbufp result : $pidval"); $rpdival = ""; if(!($pidval =~ m/ERROR/)) { $pidval = substr($pidval, 4); if($NT) { $nmupmLine = `$emdhome/bin/nmupm procinfo $pidval`; if ($nmupmLine =~ m/em_result/) { $rpidval = $pidval; } } else { open(PS_F, "ps -ef| egrep -i nmccollector|"); while () { chomp; ($uid,$pid,$ppid,$restOfLine) = split; $pidline1 = trim($pid); $pidline2 = trim($pidval); if ($pidline1 eq $pidline2) { $rpidval = $pidval; break; } } close(PS_F); } } TRACE("final result : $rpidval"); return $rpidval; }