make my script wait

is there a way to make my script wait before doing something without using the "sleep _" command?

What're you trying to do? If you explain more about "why", then someone may be able to give a better explanation; depending on your circumstances, you could use the "pause" or "wait" commands.

Or put in a "read ANS" which would cause the program to wait until the user hits ENTER before continuing on to the next line in the script... alternatively, see the following thread for a way to have the user be able to hit any key (not just ENTER) and have the script continue on to the next line after the "read" command.

Also, it would help to know what language you are using...and it would be nice to see a snippet of your script and an explanation of what you are trying to do with it.

And maybe what your OS is would be good as well, just in case there are any default shell methods that would work depending on your shell and the language you wrote the script in.

Many shells, including ksh and bash, have a wait shell builtin
that can be used to wait for specific or previous processes
to finish e.g.

  wait
  wait <PID>
  • Finnbarr

The best example to give of wait() and notify() is the dining philosophers problem.

Look it up. It is in most operating system books or search google for specific programming
language details.

Otherwise, tell us your programming language and usage. I am sure we could give you an example.

The only reason to use sleep() is if you wanted to delay something for some reason. For instance the frames in a moving picture.