Sign in to follow this  
Followers 0
FreeRider

Ping command possible bug

9 posts in this topic

Hello,

I developed an Autoit based application used by several users from several locations.

My script uses the Ping command to detect if user is connected to a network and sometimes

the return error code is 1 (Host is offline) despite the host is online. When pinging manualy from

the DOS comamand line it works.

The only bypass I found is to ping the host using the DOS Command line and retreiving the result

through the "$STDOUT_CHILD" constant. Doing like this avoids the error.

I assume that some of the user's locations have network restrictions which drives the ping command to

return an error. However I'd like to know if the Autoit ping command does something else than the ping it self

which could explain why I get the error (network controls or other...)

Many thanks for your help

By the way, I did not find any other scripting tool as powerful as Autoit.

Just for your information, here is the script I use :

;==============================================

; STDIO Constants

;==============================================

Global Const $STDIN_CHILD = 1

Global Const $STDOUT_CHILD = 2

Global Const $STDERR_CHILD = 4

;==============================================

Dim $PUBLICConnected

;$PUBLICConnected=Ping("www.google.com") ====> This was my first way of pinging

===> This the way I found to bypass the problem

$Foo=Run(@ComSpec & " /c ping.exe www.google.com", @SystemDir, @SW_HIDE,$STDOUT_CHILD)

While 1

$StdOutLine = StdoutRead($Foo)

If @error Then ExitLoop

If StringInStr($StdOutLine,"Ping Request could not find") > 0 Then ContinueLoop

$PUBLICConnected="YES"

ExitLoop

WEnd

If Not $PUBLICConnected Then

$Msg="Server's not responding"

MsgBox(0,"Pinging test",$Msg & @CRLF & "Result : " & @error)

Exit

Else

$Msg="Server's responding..."

MsgBox(0,"Pinging test",$Msg & @CRLF & "Resultat : " & $PUBLICConnected)

Exit

EndIf


FreeRiderHonour & Fidelity

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Well I used that a while ago. There are a couple of methods for checking internet access.

As I understood it, your AutoIt ping SOMETIMES returns error==1 when it shouldn't, right?

Well you know ping CAN return false negatives. It happens. Well, they're not false, but we could treat them like small casual glitches and a ton of luck all in that very instant.

For that IMO you could use something like

$ping_errors=0
$ping_errors_warn=4 ; will warn the user after four consecutive errors (put anything here)

While 1
If Ping("www.g00gle.com")<1 Then ; edit: the same as Ping("xyz") followed by If @error<>0 Then...
    $ping_errors+=1 ; adds an error
Else
    $ping_errors=0 ; edit: resets the counter
EndIf

If $ping_errors>=$ping_errors_warn Then ; edit: here it reaches the minimum error count set above, before the While loop
    ; error handling here
    ; at this point it's most probable that internet connection is down
EndIf
WEnd

What do you think? Try it and tell us if this solves <_<

footswitch

EDIT: code comments added

Edited by footswitch

Share this post


Link to post
Share on other sites

See my post in your other topic. #423054

Share this post


Link to post
Share on other sites

Hi Bert,

Autoit Version is 3.2.8.1 and OS is WinXP Profressional SP2.

And by the way my purpose was only to try to understand why the Autoit ping command returns false error while the dos ping command works...

I found a bypass using always the DOS command line instead of the Autoit one and it works at all times.

I think on some of the location where users try to ping (using autoit commande) the network configuration is more secured or restricted and this drives Autoit

to retreive a wrong return code.

That's why I ask in my request if the autoit ping command performes other action than the ping it self ?

Anyway thanks for your answer


FreeRiderHonour & Fidelity

Share this post


Link to post
Share on other sites

Hi footswitch,

I found a similar bypass (see my script sample in the orignal message) which works at all times.

Thanks for your help


FreeRiderHonour & Fidelity

Share this post


Link to post
Share on other sites

Hi ptrex,

Here are answers to your questions

1 do you use the CMD -> Ping command or the AU3 ping command ?

Both... except that Autoit one sometimes return a wrong error code. This always happens from the same locations.

2. do a test and see if you can ping manually, result OK or not ?

Extract from my original posting

My script uses the Ping command to detect if user is connected to a network and sometimes

the return error code is 1 (Host is offline) despite the host is online. When pinging manualy from

the DOS comamand line it works.

3. check the firewall settings on the local PC using os XP

Local PC Firewall configuration is never modified whatever the location where user is

4. etc.

I found a bypass using always the DOS Ping command (see my script in the original posting).

The purpose of my report was to know if the Autoit ping command does something else (controls, etc...) than the ping itself.

What I assume is some of the locations where users are connected have restricted network functions and may be this drives the Autoit ping command

to receive a return wrong return code.

What's clear is this anomaly is minor and as it can be bypassed.

Many thanks for your help.


FreeRiderHonour & Fidelity

Share this post


Link to post
Share on other sites

...

I found a bypass using always the DOS Ping command (see my script in the original posting).

The purpose of my report was to know if the Autoit ping command does something else (controls, etc...) than the ping itself.

What I assume is some of the locations where users are connected have restricted network functions and may be this drives the Autoit ping command

to receive a return wrong return code.

What's clear is this anomaly is minor and as it can be bypassed.

...

Let me say I have that curiosity as well, but consider this: pings can be personalized. Maybe AutoIt's is a little different in packet size and timeout behaviour, for instance.

Just a thought.

But actually, in my case, AutoIt's ping fails as many times as MS' ping.exe. But there you go, you said it only happens with specific GSM connections, right?

If you have the time, why don't you run ethereal and take a look at the packet differences yourself, if any?

Regards

footswitch


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