jdk/test/sun/tools/jcmd/jcmd_pid_Output1.awk
changeset 22771 e2ad29fc5416
parent 22770 0cbd539cce7a
parent 22740 ab191bdb1dc9
child 22773 76673a1bac03
equal deleted inserted replaced
22770:0cbd539cce7a 22771:e2ad29fc5416
     1 #
       
     2 
       
     3 # section 0 = [PID]:
       
     4 # section 1 = "The following commands are available:"
       
     5 # section 2 = <list of commands, one command per line>
       
     6 # section 3 = blank line
       
     7 # section 4 = "For more information about a specific command use 'help <command>'."
       
     8 
       
     9 BEGIN	{
       
    10     totallines=0; matched=0; section=0;
       
    11 }
       
    12 
       
    13 # match the first line (PID of the JVM followed by ':')
       
    14 /^[0-9]+:/{
       
    15     if(section==0) {
       
    16 	matched++;
       
    17 	section=1;
       
    18     }
       
    19 }
       
    20 
       
    21 /^The following commands are available:$/{
       
    22     if(section==1) {
       
    23 	matched++;
       
    24 	section=2;
       
    25     }
       
    26 }
       
    27 
       
    28 # match a command name
       
    29 /^[a-z|A-Z][a-z|A-Z|0-9|\.|_]*$/{
       
    30     if(section==2) {
       
    31 	matched++;
       
    32     }
       
    33 }
       
    34 
       
    35 /^$/{
       
    36     if(section==2) {
       
    37 	matched++;
       
    38 	section=4;
       
    39     }
       
    40 }
       
    41 
       
    42 /^For more information about a specific command use 'help <command>'\.$/{
       
    43     if(section==4) {
       
    44 	matched++;
       
    45 	section=5;
       
    46     }
       
    47 }
       
    48 
       
    49 { totallines++; print $0 }
       
    50 
       
    51 END {
       
    52     if ((totallines > 0) && (matched == totallines)) {
       
    53 	exit 0
       
    54     }
       
    55     else {
       
    56 	exit 1
       
    57     }
       
    58 }