Pause script (wsleep) after ping reply

Author Message
piet200

  • Total Posts : 4
  • Scores: 0
  • Reward points : 0
  • Joined: 11/25/2011
  • Status: offline
Pause script (wsleep) after ping reply Friday, November 25, 2011 2:19 AM (permalink)
0
Hi,

I have a nice little script which ping's a certain IP address and if the address is online another piece of code is executed (sub1, sub2)
Although, I use to do some post install tasks after a linux server has been installed. It does the job fine, but when the newly installed server gives a ping reply it is still going to reboot for the last time.

So when my script starts copying files to the server it will become unavailable for a while.
Since I know how long it will take to reboot I want to build in a pause in the script to let it wait for a few minutes before calling "sub1" and "sub2" in the example below.

The bottom three lines work fine as a separate script. the "WScript.Sleep" command does it's job.
But when I integrate it into the script above it gives errors.
As I am a newby with scripting, I hope someone can help me out.



*****
Sub Window_onLoad
Set objShell = CreateObject("WScript.Shell")
boolPinged = Ping("10.10.10.10")
While boolPinged = False
' Wait for one second, given by -n #
objShell.Run "cmd /c ping -n 1 localhost > nul", 0, True
boolPinged = Ping("10.10.10.10")
Wend
Call sub1
Call sub2
End Sub
*****
Set objsh = WScript.CreateObject("WScript.Shell")
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
WScript.Sleep 5000
*****

 
#1
    themcse

    • Total Posts : 171
    • Scores: 1
    • Reward points : 0
    • Joined: 12/29/2008
    • Status: offline
    Re:Pause script (wsleep) after ping reply Sunday, November 27, 2011 5:26 PM (permalink)
    0
    What is the host for this script?  The Window_onLoad sounds like browser, but security would be an issue for shell interaction (unless in HTA)?  Does the hackish attempt to sleep (using ping -n) work in the context of the original script?  Are you trying to replace this with WScript.Sleep?  Details of the error that you're encountering will likely make diagnosis easier.  Kind regards.
     
    #2
      piet200

      • Total Posts : 4
      • Scores: 0
      • Reward points : 0
      • Joined: 11/25/2011
      • Status: offline
      Re:Pause script (wsleep) after ping reply Sunday, November 27, 2011 6:19 PM (permalink)
      0
      The Host for this script is a VMware ESXi host.
      I use this script since I found it on the internet and does what I want.
       
      The only issue I experience is that the script continues to execute when there is a ping reply, and that happens after the ESXi installation is finished before the host reboots.
      So my script starts executing another job and the host is just about to reboot, therefor I want the script to wait for another couple of minutes when the ping reply is there.
      So I thought it would be the easiest way to use the sleep command. is there any other solution for this ?
       
       
       
       
       
      #3
        59cobalt

        • Total Posts : 979
        • Scores: 91
        • Reward points : 0
        • Joined: 7/17/2011
        • Status: offline
        Re:Pause script (wsleep) after ping reply Monday, November 28, 2011 5:38 AM (permalink)
        0
        piet200
        The Host for this script is a VMware ESXi host.
        The ping target is unimportant. What is the environment in which your script code is running? HTA? Regular web page? Standalone VBScript? What errors do you get when using WScript.Sleep()?
        piet200
        So I thought it would be the easiest way to use the sleep command.
        Yes, it would. Provided the runtime environment gives access to the WScript object.
         
        #4
          ehvbs

          • Total Posts : 3320
          • Scores: 110
          • Reward points : 0
          • Joined: 6/22/2005
          • Location: Germany
          • Status: offline
          Re:Pause script (wsleep) after ping reply Monday, November 28, 2011 11:04 AM (permalink)
          0
          "Sub Window_onLoad" ==> .HTML/.HTA ==> no WScript (this object is provided by the c/wscript.exe host.
          "' Wait for one second, given by -n #" - wrong, see ping /?:
          -n count       Number of echo requests to send.
          See the FAQ
          http://www.visualbasicscr...sked-Stuff-m47117.aspx
          for
          How can I pause an HTA? What can I use in an HTA instead of WScript.Sleep?
           
           
           
          #5
            59cobalt

            • Total Posts : 979
            • Scores: 91
            • Reward points : 0
            • Joined: 7/17/2011
            • Status: offline
            Re:Pause script (wsleep) after ping reply Monday, November 28, 2011 11:19 AM (permalink)
            0
            ehvbs
            "' Wait for one second, given by -n #" - wrong, see ping /?:
            -n count       Number of echo requests to send.
            Meaning you need a count of k+1 for a k second delay.
             
            #6
              ehvbs

              • Total Posts : 3320
              • Scores: 110
              • Reward points : 0
              • Joined: 6/22/2005
              • Location: Germany
              • Status: offline
              Re:Pause script (wsleep) after ping reply Monday, November 28, 2011 11:38 AM (permalink)
              0
              Correct, I wasn't aware of the (default?) 1 sec delay:
              TimeThis :  Command Line :  ping -n 4 localhost 
              TimeThis :    Start Time :  Tue Nov 29 00:36:20 2011
              TimeThis :      End Time :  Tue Nov 29 00:36:23 2011
              TimeThis :  Elapsed Time :  00:00:03.354
               
               
              #7

                Online Bookmarks Sharing: Share/Bookmark

                Jump to:

                Current active users

                There are 0 members and 1 guests.

                Icon Legend and Permission

                • New Messages
                • No New Messages
                • Hot Topic w/ New Messages
                • Hot Topic w/o New Messages
                • Locked w/ New Messages
                • Locked w/o New Messages
                • Read Message
                • Post New Thread
                • Reply to message
                • Post New Poll
                • Submit Vote
                • Post reward post
                • Delete my own posts
                • Delete my own threads
                • Rate post

                2000-2012 ASPPlayground.NET Forum Version 3.9