- 论坛徽章:
- 0
|
本帖最后由 princeduan 于 2012-02-08 12:46 编辑
- #! /opt/perl/bin/perl
- #
- #xp4 ps wrapper
- #
- $ENV{UNIX95}=qq(XPG4);
- #
- #-o arg definition
- #
- #ps -el + VSZ
- $0_arg = qq(flags,state,user,pid,ppid,cpu,intpri,nice,addr,sz,vsz,wchan,stime,tty,time,args);
- #ps -ef + sz,vsz
- $o_arg = qq(user,pid,ppid,cpu,stime,tty,time,sz,vsz,args);
- #-C ag definition
- $C_arg = qq();
- $header = 1;
- $filter = qq(oracle|hul|jp1);
- $cmd = qq(ps -o $o_arg);
- if ($C_arg =~ /`$/) {
- $cmd .= qq(-e);
- } else {
- $cmd .= qq(-C $C_arg);
- }
- open(FH, "$cmd |") || die;
- while (<FH>) {
- if ($header) {
- print;
- $header = 0;
- } else {
- if ($filter =~ /`$/) {
- print;
- } elsif (/$filter/) {
- print;
- }
- }
- }
- close(FH);
- exit 0;
复制代码 谢谢!:wink: |
|