Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Batch file pause

  • 05-03-2005 07:27PM
    #1
    Registered Users, Registered Users 2 Posts: 3,357 ✭✭✭


    Hi,
    Basically I need to write a batch file that will, say ping Google once every hour. I'm grand with basic batch files, but is there a command to pause the file for a set period of time?

    If not, is there any other method by which I could flick back easily to see if and when a client was detached from the network?

    Thank You
    Snapscan


Comments

  • Registered Users, Registered Users 2 Posts: 11,985 ✭✭✭✭zAbbo


    ping www.google.ie -w 60000

    or something


  • Registered Users, Registered Users 2 Posts: 3,357 ✭✭✭snappieT


    That doesn't do it - it just extends the time PING waits for a reply before claiming that the packet was lost.
    Thanks anyway

    Any more ideas?


  • Registered Users, Registered Users 2 Posts: 11,985 ✭✭✭✭zAbbo


    stick a wait in there, theres plenty of info, google


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 95,888 Mod ✭✭✭✭Capt'n Midnight


    Use Choice.com from Dos/Win9x - works on later versions of windows too.

    choice /T:Y,99

    Note: only waits up to 99 seconds
    There are probably a couple of thousand utils like this out there,
    including the ones on the windows Resource kits " wait "

    To see when the connection was lost - debug this
    [php]:loop
    ping x -n | find "No Reply"
    if errorlevel 1 goto loop
    echo. | time >>timeout.txt
    goto loop[/php]


  • Registered Users, Registered Users 2 Posts: 3,357 ✭✭✭snappieT


    Wait doesn't exist, and choice.com isn't available (Win XP Pro SP2)

    I looked at google, but came up with nothing.
    Is there any other methods or stand-alone programs?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,762 ✭✭✭WizZard


    Set up a scheduled job in Windows? Set it to run your batch file every hour at whatever time, then get your batch file to output to a file.

    <edit>Just noticed that windows smallest time period for a scheduled task is 24hrs. So it's not good. </edit>


  • Registered Users, Registered Users 2 Posts: 78 ✭✭de8o


    You need sleep.exe. It comes with the resource CD but I think M$ allow you to download it now. Works great in batch files.


  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    I'll write you an app that does it. I can do it on Wednesday. If you have perl installed I'll write you a script now.

    Edit: I have a copy of sleep here. pm me your email address and I'll send it to you. I take no responsibility if it wrecks your computer, etc. etc.


  • Registered Users, Registered Users 2 Posts: 3,357 ✭✭✭snappieT


    Savage! Cheers de80


  • Registered Users, Registered Users 2 Posts: 1,065 ✭✭✭Snowbat


    You can also find a sleep.exe here (3rd file):
    http://www.computerhope.com/dutil.htm


  • Advertisement
  • Moderators, Arts Moderators Posts: 36,202 Mod ✭✭✭✭pickarooney


    copy these two lines into a file called wait.bat and save it in a directory which is in your PATH
    @ping 127.0.0.1 -n 2 -w 1000 > nul
    @ping 127.0.0.1 -n %1% -w 1000> nul
    

    To use it in a batch file just call wait n where n is the number of seconds.

    Note: the ping command here is not actually used for the pinging you want to do, it's simply pinging the machine itself (or a null address would work equally well) and creating the delay.


Advertisement