Jump to content

pinging


Recommended Posts

i'm tring to create a program that will ping my router, and if i do not get a response, it will execute another program

here is my code

ping ("192.168.1.10") if @error =1 Then ShellExecute("c:\myscript.vbs")

Sleep(3000)

then idealy i would like it to loop, starting all over

please help, i've looked at all the examples on here, and i'm stumped

Link to comment
Share on other sites

Hi there,

Check

While
and
Wend
commands.

Cheers

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Link to comment
Share on other sites

i'm having problems with the pinging syntax.....

i got it to work

While 1
    
    Ping("192.168.1.1")
    If @error =1 Then ShellExecute("c:\myscript.vbs")
        Sleep(3000)
        
        WEnd
Link to comment
Share on other sites

  • 3 months later...

ok so this is wat I got

$var = ""

msgbox(0,$device, $var & " ms." & " Before." ) Result --> window with pc01 then blank ms. Before.

$var = Ping($device,10000)

msgbox(0,$device,$var & " ms" & " After.") Result --> window with pc01 then 0 ms. After.

IS that 0 correct ? How acurate is that ping command in AutoIT ???

If I ping in dos I seem to get a steady 4ms., 5ms or 6ms.

I'm trapping for Error's now and I'm getting all Error 4 's even though it says the ping returned 0

This some NEW BUG??????

Edited by Ghost21
Link to comment
Share on other sites

I hate to *BUMP* things but this stops my whole script from running because I can't trust the results coming back from Autoits ping can someone help me on this one..

The strange part is this time I know its not me.. Well it could be me but I don't think so..

msgbox(0,$device,$ping)

$ping = Ping($device,10000)

msgbox(0,$device,$ping)

Returns a $Device name and blank in the message box.. " Perfect ping has nothing in it.. "

slight pause cause of the 10000 timeout just for testing

Returns a $Device name and 0 in the message box.. " WTF something is messed up with ping..."

HELP!!! :graduated:

Edited by Ghost21
Link to comment
Share on other sites

When Ping can't reach the address, it returns 0, so if you get a 0 as a return, then Ping didn't find the address and nothing was returned.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

In a test script the code below runs fine.. Same with the Autoit Script ping.

Inside the script when this is run it comes back like the ping is in the wrong syntax.. Any idea what could be effecting both pings inside my script...

$device = "PC001"
$Reply = ""
  $Testping = Run(@ComSpec & " /c " & 'ping.exe ' & $device & " -n 1 -w 500 " & '| find "Reply" ', @WindowsDir, @SW_SHOW, $STDOUT_CHILD)
While ProcessExists($Testping)
  Sleep(10)
  $Reply &= StdoutRead($Testping)
  If @error Then ExitLoop
WEnd
  $ReplySplit = StringSplit($Reply, " ")
If $ReplySplit >= 6 Then
  $IP = StringTrimRight($ReplySplit[3], 1)
  $Ping = StringTrimLeft($ReplySplit[5], 5)
EndIf
MsgBox(0,"IP: " & $ip , "Ping: " & $ping)
Link to comment
Share on other sites

What's the error message you get when you run that script?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I'm not sure why it's not working for you, but I ran that exact script, except I changed the $device variable to a computer on my network, and I got a message box with the correct information. (Win 7 x86)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Use /k instead of /c after the @Comspec and it should keep the window open to allow you to see the command console.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

OK this is tottally screwed.. I got it working by doing this

$Testping = Run(@ComSpec & " /c " & "ping -n 1 -w 500 PC001 | find ""Reply""", "", @SW_SHOW, $STDOUT_CHILD)

That worked .. but the just $device doesn't.. even though right before it I did a msgbox(0,"",$device) and it showed the device name no problem..

$Testping = Run(@ComSpec & " /c " & "ping -n 1 -w 500 " & $Device & " | find ""Reply""", "", @SW_SHOW, $STDOUT_CHILD)

:graduated:

Link to comment
Share on other sites

I had similar issues with the Ping() command. I could ping a device from a CMD window and get replies, but the Ping() command returned fails every time. I never could get to the root of the problem.

As it was part of a script to load balance, it was essential that I got reliable info so I ended up using :-

Run(@ComSpec & " /c ping <devicename/IP>")

which worked absolutely fine.

It was really frustrating for quite a while

[font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font]

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...