OneJeremias Posted April 16, 2014 Posted April 16, 2014 I'm working with the built-in Ping function, and it seems to ping computers on my own subnet just fine, but it fails to ping any computer on a different subnet. I can ping those same computers from the command line just fine. Is this by design, and is there anything I can do about it? Thanks!
JohnOne Posted April 17, 2014 Posted April 17, 2014 What is state of @error? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
OneJeremias Posted April 17, 2014 Author Posted April 17, 2014 @error contains 4, which according to the documentation is the least helpful possibility: "other errors"
JohnOne Posted April 17, 2014 Posted April 17, 2014 Show both command line and AutoIt code. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
OneJeremias Posted April 17, 2014 Author Posted April 17, 2014 (edited) $pingtest = Ping(StringTrimLeft($hosts, 2)) MsgBox(0, "show error", @error) If $pingtest <> 0 Then Run("explorer.exe /root," & $hosts & "\c$") Else MsgBox(0, "Computer unavailable", "Unable to connect to the computer you requested. The computer may be off...") EndIf I'm not sure how to upload an image (image button just asks for a link), but the command line is as follows: C:WindowsSystem32>ping 01055w7 Pinging 01055w7.domain.com [10.21.31.124] with 32 bytes of data: Reply from 10.21.31.124: bytes=32 time=1ms TTL=127 Reply from 10.21.31.124: bytes=32 time=3ms TTL=127 Reply from 10.21.31.124: bytes=32 time=1ms TTL=127 Reply from 10.21.31.124: bytes=32 time=1ms TTL=127 Ping statistics for 10.21.31.124: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 1ms, Maximum = 3ms, Average = 1ms Edited April 18, 2014 by OneJeremias
Developers Jos Posted April 17, 2014 Developers Posted April 17, 2014 (edited) You need to specify the total host name when using ping and not expect that the domain search suffix is applied automatically. Jos Edited April 17, 2014 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
OneJeremias Posted April 18, 2014 Author Posted April 18, 2014 (edited) That seems to break it completely. To clarify what I changed: Old method (worked within my own subnet): Ping("01055w7") where 01055w7 is the host name of the computer to ping. Your method (@ error now set to 4 every time): Ping("01055w7.domain.com") Full disclosure: I am passing Ping a string in this manner: Ping(StringTrimLeft("01055w7.domain.com", 2), because I have a function that returns the computer name. The change I made was to that function, which now appends .domain.com to the end. As I said though, Ping works if I do NOT append .domain.com to the end. Update: I was just doing some more playing around, and noticed that today the @error is coming back as 0. I checked what Ping is returning, and it is also 0. I thought @error was supposed to be set to non-zero if Ping returned 0? Edited April 18, 2014 by OneJeremias
Developers Jos Posted April 18, 2014 Developers Posted April 18, 2014 (edited) this: ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : Ping(StringTrimLeft("\\01055w7.domain.com", 2)) = ' & Ping(StringTrimLeft("\\01055w7.domain.com", 2)) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : StringTrimLeft("\\01055w7.domain.com", 2) = ' & StringTrimLeft("\\01055w7.domain.com", 2) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Returns: @@ Debug(1) : Ping(StringTrimLeft("\\01055w7.domain.com", 2)) = 149 >Error code: 0 @@ Debug(2) : StringTrimLeft("\\01055w7.domain.com", 2) = 01055w7.domain.com >Error code: 0 So seems to work fine. Jos Edited April 18, 2014 by Jos removed real domain on request SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
OneJeremias Posted April 18, 2014 Author Posted April 18, 2014 (edited) Hmm, not sure what the deal is then. I'll play around with it a little more and see what's up. Thanks. Edited April 18, 2014 by OneJeremias
OneJeremias Posted November 10, 2014 Author Posted November 10, 2014 Finally getting back to this project after a long hiatus. Just as an FYI to anyone else who may be having this problem: Jos was spot on in his help above. My host name had an additional space at the end of the string that I didn't see until I tried to append my domain name to the end and outputted to a msgbox. Doh. :-) Thanks Jos!
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