Sign in to follow this  
Followers 0
MattX

Ping Help

5 posts in this topic

I have an ini file:

[Addresses]
address1=10.0.0.2
address2=10.0.0.3
address3=10.0.0.4
address4=10.0.0.6
address5=10.0.0.7
address6=10.0.0.8
address7=10.0.0.9

And this script:

$addresslist = IniReadSection(@ScriptDir & '\addresses.ini', 'Addresses')
If @error Then
    MsgBox(4096, "", "Error occured, probably no INI file.")
Else
    For $i = 1 To $addresslist[0][0]
        $var = ping($addresslist[$i][1])
        If $var Then
    Msgbox(0,"Status","Online, roundtrip was:" & $var)
Else
    Msgbox(0,"Status","An error occured with number: " & @error)
EndIf        
    Next
    EndIf

And the odd thing is at the end when it hits address 10.0.0.9 [ which I know it will error on ] the msgbox states:

An error occured with number 2

It should be number 7 - anyone know why ?

Also I am wondering if anyone could point me in the right direction in writing the status of the pings to a log file by using the _FileWriteLog function ?

Share this post


Link to post
Share on other sites



I have an ini file:

[Addresses]
address1=10.0.0.2
address2=10.0.0.3
address3=10.0.0.4
address4=10.0.0.6
address5=10.0.0.7
address6=10.0.0.8
address7=10.0.0.9

And this script:

$addresslist = IniReadSection(@ScriptDir & '\addresses.ini', 'Addresses')
If @error Then
    MsgBox(4096, "", "Error occured, probably no INI file.")
Else
    For $i = 1 To $addresslist[0][0]
        $var = ping($addresslist[$i][1])
        If $var Then
    Msgbox(0,"Status","Online, roundtrip was:" & $var)
Else
    Msgbox(0,"Status","An error occured with number: " & @error)
EndIf        
    Next
    EndIf

And the odd thing is at the end when it hits address 10.0.0.9 [ which I know it will error on ] the msgbox states:

An error occured with number 2

It should be number 7 - anyone know why ?

Also I am wondering if anyone could point me in the right direction in writing the status of the pings to a log file by using the _FileWriteLog function ?

if you look in the help you will see that @error set to 2 means "Host is unreachable"

if you want to know which one errored you should replace @error with $i

Msgbox(0,"Status","An error occured with number: " & $i)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thanks, just got to work on getting all this info piped into a log file now.....

Share this post


Link to post
Share on other sites

#include <file.au3>

Dim $sLogPath = "c:\matt\log.txt"
Dim $sLogMsg = "Ping On  " 

$addresslist = IniReadSection(@ScriptDir & '\addresses.ini', 'Addresses')
If @error Then
    MsgBox(4096, "", "Error occured, probably no INI file.")
Else
    For $i = 1 To $addresslist[0][0]
        $var = ping($addresslist[$i][1])
        If $var Then
        ;_FileWriteLog($sLogPath, $sLogMsg)

   ;Msgbox(0,"Status","Online, roundtrip was:" & $var)
Else
    Msgbox(0,"Status","An error occured with number: " & $i)
EndIf

    ;MsgBox(4096, "", "Key: " & $addresslist[$i][0] & @CRLF & "Value: " & $addresslist[$i][1])
    
    Next
    EndIf

Quick question....

How can I get the $i to return the relevant line from the .ini file ? IE the actual IP address ?

Share this post


Link to post
Share on other sites

'fink I've done it:

Msgbox(0,"Status","An error occured with number: " & $addresslist[$i][1])

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