Sign in to follow this  
Followers 0
w0uter

_NetStat()

8 posts in this topic

got boored.

again.

wanted to figure out std func's.

made this.

Func _NetStat()
    
    Local $v_NETSTAT
    
    $v_NETSTAT = Run(@SystemDir & '\netstat.exe', @SystemDir, @SW_HIDE, 2)
    $v_NETSTAT = StdoutRead ($v_NETSTAT)
    
    $v_NETSTAT = StringTrimLeft($v_NETSTAT, StringInStr($v_NETSTAT, @LF, 0, 4))
    $v_NETSTAT = StringLeft($v_NETSTAT, StringInStr($v_NETSTAT, @LF, 0, -1) - 1)
    
    $v_NETSTAT = StringSplit($v_NETSTAT, @LF)
    
    Local $as_Temp, $as_RET[$v_NETSTAT[0]][4]
    
    For $i = 1 To $v_NETSTAT[0]
        $v_NETSTAT[$i] = StringReplace($v_NETSTAT[$i], @CR, '')
        $v_NETSTAT[$i] = StringStripWS($v_NETSTAT[$i], 1 + 2 + 4)
        $as_Temp = StringSplit($v_NETSTAT[$i], ' ')
        $as_RET[$i - 1][0] = $as_Temp[1]
        $as_RET[$i - 1][1] = $as_Temp[2]
        $as_RET[$i - 1][2] = $as_Temp[3]
        $as_RET[$i - 1][3] = $as_Temp[4]
    Next
    
    Return $as_RET
    
EndFunc  ;==>_NetStat

dim $v_lol = _NetStat()

For $i = 0 To UBound($v_lol) - 1
    For $x = 0 To 3
        ConsoleWrite('-' & $v_lol[$i][$x] & @LF)
    Next
    ConsoleWrite(@LF)
Next

_NetStat.au3


My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites



got boored.

again.

wanted to figure out std func's.

made this.

Func _NetStat()
    
    Local $v_NETSTAT
    
    $v_NETSTAT = Run(@SystemDir & '\netstat.exe', @SystemDir, @SW_HIDE, 2)
    $v_NETSTAT = StdoutRead ($v_NETSTAT)
    
    $v_NETSTAT = StringTrimLeft($v_NETSTAT, StringInStr($v_NETSTAT, @LF, 0, 4))
    $v_NETSTAT = StringLeft($v_NETSTAT, StringInStr($v_NETSTAT, @LF, 0, -1) - 1)
    
    $v_NETSTAT = StringSplit($v_NETSTAT, @LF)
    
    Local $as_Temp, $as_RET[$v_NETSTAT[0]][4]
    
    For $i = 1 To $v_NETSTAT[0]
        $v_NETSTAT[$i] = StringReplace($v_NETSTAT[$i], @CR, '')
        $v_NETSTAT[$i] = StringStripWS($v_NETSTAT[$i], 1 + 2 + 4)
        $as_Temp = StringSplit($v_NETSTAT[$i], ' ')
        $as_RET[$i - 1][0] = $as_Temp[1]
        $as_RET[$i - 1][1] = $as_Temp[2]
        $as_RET[$i - 1][2] = $as_Temp[3]
        $as_RET[$i - 1][3] = $as_Temp[4]
    Next
    
    Return $as_RET
    
EndFunc ;==>_NetStat

dim $v_lol = _NetStat()

For $i = 0 To UBound($v_lol) - 1
    For $x = 0 To 3
        ConsoleWrite('-' & $v_lol[$i][$x] & @LF)
    Next
    ConsoleWrite(@LF)
Next
sorry for the bump, but it really helped me. thanks for sharing it.

Share this post


Link to post
Share on other sites

F:\Documents and Settings\Admin\Desktop\_NetStats.au3 (20) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$as_RET[$i - 1][1] = $as_Temp[2]

$as_RET[$i - 1][1] = ^ ERROR

>Exit code: 1 Time: 1.009

how to resolve this error?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Func _NetStat()
    Local $v_NETSTAT
    $v_NETSTAT = Run(@SystemDir & '\netstat.exe', @SystemDir, @SW_HIDE, 2)
    $v_NETSTAT = StdoutRead($v_NETSTAT)

    $v_NETSTAT = StringTrimLeft($v_NETSTAT, StringInStr($v_NETSTAT, @LF, 0, 4))
    $v_NETSTAT = StringLeft($v_NETSTAT, StringInStr($v_NETSTAT, @LF, 0, -1) - 1)

    $v_NETSTAT = StringSplit($v_NETSTAT, @LF)

    Local $as_Temp, $as_RET[$v_NETSTAT[0]][4]
    For $i = 1 To $v_NETSTAT[0]
        $v_NETSTAT[$i] = StringReplace($v_NETSTAT[$i], @CR, '')
        $v_NETSTAT[$i] = StringStripWS($v_NETSTAT[$i], 1 + 2 + 4)
        $as_Temp = StringSplit($v_NETSTAT[$i], ' ')
        If UBound($as_Temp) > 1 Then $as_RET[$i - 1][0] = $as_Temp[1]
        If UBound($as_Temp) > 2 Then $as_RET[$i - 1][1] = $as_Temp[2]
        If UBound($as_Temp) > 3 Then $as_RET[$i - 1][2] = $as_Temp[3]
        If UBound($as_Temp) > 4 Then $as_RET[$i - 1][3] = $as_Temp[4]
    Next

    Return $as_RET
EndFunc   ;==>_NetStat

Edited by Robjong

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I like this one too...

#include <Array.au3>
#include <Process.au3>

dim $v_lol = _NetStat()

_ArrayDisplay($v_lol)

Func _NetStat()
    
    Local $v_NETSTAT = ""
    
    $pid_NETSTAT = Run(@SystemDir & '\netstat.exe -a -o', @SystemDir, @SW_HIDE, 2)
    
    While ProcessExists($pid_NETSTAT)
        $v_NETSTAT &= StdoutRead($pid_NETSTAT)
    WEnd
    
    $v_NETSTAT = StringTrimLeft($v_NETSTAT, StringInStr($v_NETSTAT, @LF, 0, 4))
    $v_NETSTAT = StringLeft($v_NETSTAT, StringInStr($v_NETSTAT, @LF, 0, -1) - 1)
    
    $v_NETSTAT = StringSplit($v_NETSTAT, @LF)
    
    Local $as_Temp, $as_RET[$v_NETSTAT[0] + 1][6]
    
    $as_RET[0][0] = $v_NETSTAT[0]
    
    For $i = 1 To $v_NETSTAT[0]
        $v_NETSTAT[$i] = StringReplace($v_NETSTAT[$i], @CR, '')
        $v_NETSTAT[$i] = StringStripWS($v_NETSTAT[$i], 1 + 2 + 4)
        $as_Temp = StringSplit($v_NETSTAT[$i], ' ')
        
        If $as_Temp[1] = "TCP" Then
            $as_RET[$i][0] = $as_Temp[1]
            $as_RET[$i][1] = $as_Temp[2]
            $as_RET[$i][2] = $as_Temp[3]
            $as_RET[$i][3] = $as_Temp[4]
            $as_RET[$i][4] = $as_Temp[5]
            $as_RET[$i][5] = _ProcessGetName($as_Temp[5])
        EndIf
        
        If $as_Temp[1] = "UDP" Then
            $as_RET[$i][0] = $as_Temp[1]
            $as_RET[$i][1] = $as_Temp[2]
            $as_RET[$i][2] = $as_Temp[3]
            $as_RET[$i][3] = "*:*"
            $as_RET[$i][4] = $as_Temp[4]
            $as_RET[$i][5] = _ProcessGetName($as_Temp[4])
        EndIf
        
    Next
    
    Return $as_RET
    
EndFunc  ;==>_NetStat
Edited by SoulA

Share this post


Link to post
Share on other sites

$as_RET[$i - 1][3] = "*:("

Aw, I think UDP has a crush on somebody.

Code tags prevent that from happening, for future reference :mellow:

#include <Array.au3>
#include <Process.au3>

dim $v_lol = _NetStat()

_ArrayDisplay($v_lol)

Func _NetStat()
   
    Local $v_NETSTAT = ""
   
    $pid_NETSTAT = Run(@SystemDir & '\netstat.exe -a -o', @SystemDir, @SW_HIDE, 2)
   
    While ProcessExists($pid_NETSTAT)
        $v_NETSTAT &= StdoutRead($pid_NETSTAT)
    WEnd
   
    $v_NETSTAT = StringTrimLeft($v_NETSTAT, StringInStr($v_NETSTAT, @LF, 0, 4))
    $v_NETSTAT = StringLeft($v_NETSTAT, StringInStr($v_NETSTAT, @LF, 0, -1) - 1)
   
    $v_NETSTAT = StringSplit($v_NETSTAT, @LF)
   
    Local $as_Temp, $as_RET[$v_NETSTAT[0]][6]
   
    For $i = 1 To $v_NETSTAT[0]
        $v_NETSTAT[$i] = StringReplace($v_NETSTAT[$i], @CR, '')
        $v_NETSTAT[$i] = StringStripWS($v_NETSTAT[$i], 1 + 2 + 4)
        $as_Temp = StringSplit($v_NETSTAT[$i], ' ')
       
        If $as_Temp[1] = "TCP" Then
            $as_RET[$i - 1][0] = $as_Temp[1]
            $as_RET[$i - 1][1] = $as_Temp[2]
            $as_RET[$i - 1][2] = $as_Temp[3]
            $as_RET[$i - 1][3] = $as_Temp[4]
            $as_RET[$i - 1][4] = $as_Temp[5]
            $as_RET[$i - 1][5] = _ProcessGetName($as_Temp[5])
        EndIf
       
        If $as_Temp[1] = "UDP" Then
            $as_RET[$i - 1][0] = $as_Temp[1]
            $as_RET[$i - 1][1] = $as_Temp[2]
            $as_RET[$i - 1][2] = $as_Temp[3]
            $as_RET[$i - 1][3] = "*:*"
            $as_RET[$i - 1][4] = $as_Temp[4]
            $as_RET[$i - 1][5] = _ProcessGetName($as_Temp[4])
        EndIf
       
    Next
   
    Return $as_RET
   
EndFunc ;==>_NetStat

Share this post


Link to post
Share on other sites

screw that its cute.

Share this post


Link to post
Share on other sites

screw that its cute.

Yeahh..... No.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0