Joboy2k Posted April 15, 2010 Posted April 15, 2010 hey all im having a problem. i just started making a script that i want to constantly run through pings - "192.168.1.1" through to "192.168.1.256" im using this so if a new device is connected it will bring up a warning and also help me see if everything that is supposed to be connected is. but i cant find a good method of going through 256 different pings. this is what i did but it didnt work. dim $array[256] For $i = 1 to 256 $check = ping("192.168.1."&$array[$i],1000) if $check Then Msgbox(0,"Ip Connected","192.168.1."&$array[$i]) Else Msgbox(0,"Ip NOT Connected","192.168.1."&$array[$i]) EndIf next all it keeps saying is "Ip NOT Connected" "192.168.1" so obviously my $array wont work in the ping command line. is there any suggestion you could give me on a more simpilar way of going about this or maybe what im doing wrong. thanks in advance
99ojo Posted April 15, 2010 Posted April 15, 2010 (edited) Hi, you are using an empty array. You also should think about your message boxes -> 254 MsgBox's would popup. Have a look for ToolTip in helpfile if ip is connected.... For $i = 1 to 254 ; 255 is reserved for broadcast, 256 non existent $check = ping("192.168.1." & $i ,1000) if $check Then Msgbox(0,"Ip Connected","192.168.1." & $i) Else Msgbox(0,"Ip NOT Connected","192.168.1." & $i) EndIf next ;-)) Stefan Edited April 15, 2010 by 99ojo
Tvern Posted April 15, 2010 Posted April 15, 2010 (edited) For $i = 1 to 256 ; should be 254 like 99ojo posted $ip = "192.168.1." & $i $check = ping($ip,1000) if $check Then Msgbox(0,"Ip Connected",$ip) Else Msgbox(0,"Ip NOT Connected",$ip) EndIf next dim $array[256] creates an array with 256 values, but all those values start of as Nill untill you assign a value to them. So if you write: "192.168.1." & $array[1] you're actually writing: "192.168.1." & "" Edit: too slow :< Edited April 15, 2010 by Tvern
Joboy2k Posted April 15, 2010 Author Posted April 15, 2010 thanks guys i noticed my stupid mistake after i posted. i got it working with this anyway. didnt need the array lol For $i = 1 to 256 step + 1 $check = ping("192.168.1."&$i,250) if $check Then Msgbox(0,"Ip Connected","192.168.1."&$i) Else EndIf next sorry for the time waste xD thanks for helping though
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now