Jump to content

Help making some changes


Recommended Posts

Hello everyone, 

I was into autoit a few years ago and changed my line of work so i never got into it, now my new job will require me to learn a lot more.

Currently i'm trying to ping a list of company IP's and write the result to a text file. 

So far I was able to use a script that i had from a long time ago, please see below;

#include <file.au3>
Dim $aIPList
If Not _FileReadToArray("IPList.txt",$aIPList) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
For $x = 1 to $aIPList[0]
    FileWriteLine ("PingLogFile.txt", $aIPList[$x] & "==> ONLINE" & Ping($aIPList[$x]))
Next

It's working perfect the way I want but need some changes done:

Right now My IPList.txt has the following for example:

42.76.52.20
42.76.52.21 
42.76.52.22
 
The result in PingLogFile.txt result:
 

42.76.52.20 ==> ONLINE 19
42.76.52.21 ==> ONLINE 0
42.76.52.22 ==> ONLINE 19
 
It's showing the status and the millisecond after it, the problem is although 42.76.52.21 is offline (0 MS) it's showing the default "ONLINE" status. 
 
Further If possible I would like to have it do a final count at how many are alive/not pingable and a cleaner output; eg:
We can even get rid of the milliseconds, I don't have the use for it. 

42.76.52.20 ==> ONLINE 19
42.76.52.21 ==> OFFLINE 0
42.76.52.22 ==> ONLINE 19
 
IP's Alive: ==> 2
Dead: ==> 1
 
 
Thanks again in advance for anyone that can help out as I have a few hundred Ip's to ping and my boss wants me to manually ping each and every single one of them and record it!
 
 
 
 
 
Link to comment
Share on other sites

Hi, maybe this:

#include <file.au3>
Local $aIPList,$count,$ms
$count=0
If Not _FileReadToArray("IPList.txt",$aIPList) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
For $x = 1 to $aIPList[0]
    $ms=Ping($aIPList[$x])
    If $ms then
    FileWriteLine ("PingLogFile.txt", $aIPList[$x] & "==> ONLINE " & $ms)
    $count+=1
    EndIf
Next
FileWriteLine("PingLogFile.txt", @CRLF & "IP's Alive: ==> " & $count & @CRLF & "Dead: ==> " & $aIPList[0]-$count)

saludos

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...