$version = "test"; $pid = get_pid($version); if ( $pid eq "" ) # if null, MEVS not running - issue command to start MEVS { @command = ("/mevs/$version/bin/mevs", "/mevs/$version/data/config_data/mevs2.cfg", "online", "&"); system(@command); # restart MEVS $pid = get_pid($version); # Get the new pid print "new pid: [$pid]\n"; # print pid . . . ############################################################################ sub get_pid ############################################################################ { my $version = $_[0]; # passed version, prod/test/qa my $command = sprintf q(ps -ef | grep %s | grep online | awk '{print $2}'), $version; # create get pid command my @output = `$command`; # get the pid(s) return $output[0]; # return new pid }