FreeRider Posted October 24, 2007 Share Posted October 24, 2007 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 Link to comment Share on other sites More sharing options...
BrettF Posted October 24, 2007 Share Posted October 24, 2007 (edited) Don't post a bug report until your support question proves it? What version? And OS?Read on... Edited October 24, 2007 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
ptrex Posted October 24, 2007 Share Posted October 24, 2007 @ Questions : 1 do you use the CMD -> Ping command or the AU3 ping command ? 2. do a test and see if you can ping manually, result OK or not ? 3. check the firewall settings on the local PC using os XP 4. etc. regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
footswitch Posted October 24, 2007 Share Posted October 24, 2007 (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 October 24, 2007 by footswitch Link to comment Share on other sites More sharing options...
weaponx Posted October 24, 2007 Share Posted October 24, 2007 See my post in your other topic. #423054 Link to comment Share on other sites More sharing options...
FreeRider Posted October 26, 2007 Author Share Posted October 26, 2007 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 Link to comment Share on other sites More sharing options...
FreeRider Posted October 26, 2007 Author Share Posted October 26, 2007 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 Link to comment Share on other sites More sharing options...
FreeRider Posted October 26, 2007 Author Share Posted October 26, 2007 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 Link to comment Share on other sites More sharing options...
footswitch Posted October 26, 2007 Share Posted October 26, 2007 ...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 commandto 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?Regardsfootswitch Link to comment Share on other sites More sharing options...
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