@@ -646,8 +646,10 @@ protected ElementContainer getNetstatResults(WebSession s)
646
646
String protocol = s .getParser ().getRawParameter (PROTOCOL , "tcp" );
647
647
648
648
String osName = System .getProperty ("os.name" );
649
+ boolean isWindows = (osName .indexOf ("Windows" ) != -1 )?true :false ;
650
+
649
651
ExecResults er = null ;
650
- if (osName . indexOf ( "Windows" ) != - 1 )
652
+ if (isWindows )
651
653
{
652
654
String cmd = "cmd.exe /c netstat -ant -p " + protocol ;
653
655
er = Exec .execSimple (cmd );
@@ -661,18 +663,24 @@ protected ElementContainer getNetstatResults(WebSession s)
661
663
String results = er .getOutput ();
662
664
StringTokenizer lines = new StringTokenizer (results , "\n " );
663
665
String line = lines .nextToken ();
664
- // System.out.println(line);
666
+ //System.out.println("line=" + line);
665
667
int start = 0 ;
668
+ int loop = 0 ;
666
669
while (start == 0 && lines .hasMoreTokens ())
667
670
{
668
- if ((line .indexOf ("Proto" ) != -1 ))
671
+ //Some Windows(non-English) does not display "Proto".
672
+ //Korean OS also use Korean characters.(Maybe japanese, chinese also - not tested)
673
+ //So nothing to display, impossible to process this lesson.
674
+ //but Windows netstat command always have 4 header line before body so...
675
+ if ((line .indexOf ("Proto" ) != -1 ) || (isWindows && loop >= 3 ))
669
676
{
670
677
start ++;
671
678
}
672
679
else
673
680
{
674
681
line = lines .nextToken ();
675
682
}
683
+ loop ++;
676
684
}
677
685
while (start > 0 && lines .hasMoreTokens ())
678
686
{
0 commit comments