#!/usr/bin/perl -w use strict; my @required = qw( CMD /bin/sh rds SysExec /oasis/bin/sysmenu /oasis/bin/TS_TextSrvcs ); # invoke ps -a using backticks, read result into a list # for each line, split on whitespace, keep 3rd element # return a list of element => undef pairs my %procs = map { (split ' ')[3], undef } qx/ps -a/; # %procs now has a key named after each process # values are empty, mere existence of the keys suffices # now for each required process, # check if it has an entry in the hash of running procs my @missing = grep !exists $procs{$_}, @required; # print the resulting list of missing processes print map "NF: $_\n", @missing; #### #!/usr/bin/perl -w use strict; my %procs = map { (split ' ')[3], undef } qx/ps -a/; print map "NF: $_\n", grep !exists $procs{$_}, qw( CMD /bin/sh rds SysExec /oasis/bin/sysmenu /oasis/bin/TS_TextSrvcs ); #### my %procs = map { chomp; $_ => undef } qx/ps -a ho comm/;