#!/usr/bin/perl
#  find tomcat process
#  #  ARGV[0] is additional parameter tomcat was started
#  #               ex) -config=sample.xml

my $jps = `ps -ef | grep "org.apache.catalina.startup.Bootstrap $ARGV[0]"`;
my $regex = '[^\s]+\s+(\d+)\s+.*java.*org\.apache\.catalina\.startup\.Bootstrap.*start';
foreach my $line ($jps) {

        if ( $line =~ /$regex/ ) {
        print $1;
                exit;
        }
}
