Joboy2k 8 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 Share this post Link to post Share on other sites
99ojo 0 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 Share this post Link to post Share on other sites
Tvern 11 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 Share this post Link to post Share on other sites
Joboy2k 8 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 Share this post Link to post Share on other sites