Give me a break!
May 17, 2008 5:03 AM Subscribe
How can I install/use the DOS batch scripting SLEEP command with Vista Ultimate? It does not exist by default. Back while scripting on XP, I used to install the free package "Windows Server 2003 Resource Kit Tools" which came with this command.
So basically, I just want to put a 60 second pause in a loop in a script. I am not looking for CPU intensive work-arounds or solutions involving cygwin.
Thanks.
So basically, I just want to put a 60 second pause in a loop in a script. I am not looking for CPU intensive work-arounds or solutions involving cygwin.
Thanks.
Here's the same in C, for qa much smaller executable:
posted by orthogonality at 6:30 AM on May 17, 2008 [1 favorite]
#include <stdio.h> #include <stdlib.h> #include <windows.h> int badargs(const char* name, const char* arg) { fprintf( stderr, "Usage %s unsigned_integral_milliseconds\n", name); if(arg) { fprintf( stderr, "Argument \"%s\" is not an unsigned integral value\n", arg) ; } return 1; } int main(int argc, char** argv) { if(argc != 2) { return badargs(argv[0], 0); } const int BASE = 10; char* p = 0 ; char* s = argv[1]; long int sleepMillis = strtol(s, &p, BASE); if(p == s || sleepMillis < 0 ) { // not unsigned number return badargs(argv[0], s); } /* printf( "Sleeping for %li milliseconds.\n", sleepMillis); */ Sleep(sleepMillis); return 0; }
posted by orthogonality at 6:30 AM on May 17, 2008 [1 favorite]
You can ping yourself X amount of times to create a delay..
ping -n 5 localhost
posted by mattdini at 8:51 AM on May 17, 2008 [1 favorite]
ping -n 5 localhost
posted by mattdini at 8:51 AM on May 17, 2008 [1 favorite]
Response by poster: timeout is simple and works great.
Thanks people!
posted by Slenny at 11:13 AM on May 17, 2008
Thanks people!
posted by Slenny at 11:13 AM on May 17, 2008
This thread is closed to new comments.
"I am not looking for CPU intensive work-arounds or solutions involving cygwin."
You'll find it most convenient to compile this using cygwin. Compile it with a static library (oh lord is it big, that's C++ IOStreams for you, port it to C if you need it smaller) and you can use it on non-cygwin equipped machines.
For sixty seconds of sleep, call it like this:
sleep 60000
posted by orthogonality at 6:23 AM on May 17, 2008