4601N/A#
4601N/A
4601N/A# section 0 = [PID]:
4601N/A# section 1 = "The following commands are available:"
4601N/A# section 2 = <list of commands, one command per line>
4601N/A# section 3 = blank line
4601N/A# section 4 = "For more information about a specific command use 'help <command>'."
4601N/A
4601N/ABEGIN {
4601N/A totallines=0; matched=0; section=0;
4601N/A}
4601N/A
4601N/A# match the first line (PID of the JVM followed by ':')
4601N/A/^[0-9]+:/{
4601N/A if(section==0) {
4601N/A matched++;
4601N/A section=1;
4601N/A }
4601N/A}
4601N/A
4601N/A/^The following commands are available:$/{
4601N/A if(section==1) {
4601N/A matched++;
4601N/A section=2;
4601N/A }
4601N/A}
4601N/A
4601N/A# match a command name
4601N/A/^[a-z|A-Z][a-z|A-Z|0-9|\.|_]*$/{
4601N/A if(section==2) {
4601N/A matched++;
4601N/A }
4601N/A}
4601N/A
4601N/A/^$/{
4601N/A if(section==2) {
4601N/A matched++;
4601N/A section=4;
4601N/A }
4601N/A}
4601N/A
4601N/A/^For more information about a specific command use 'help <command>'\.$/{
4601N/A if(section==4) {
4601N/A matched++;
4601N/A section=5;
4601N/A }
4601N/A}
4601N/A
4601N/A{ totallines++; print $0 }
4601N/A
4601N/AEND {
4601N/A if ((totallines > 0) && (matched == totallines)) {
4601N/A exit 0
4601N/A }
4601N/A else {
4601N/A exit 1
4601N/A }
4601N/A}