make my script wait


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting make my script wait
# 1  
Old 01-21-2004
make my script wait

is there a way to make my script wait before doing something without using the "sleep _" command?
# 2  
Old 01-21-2004
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.

https://www.unix.com/unix-for-dummies-questions-and-answers/3197-making-sh-wait-user-input.html?s=

Last edited by oombera; 01-21-2004 at 05:03 PM..
# 3  
Old 01-22-2004
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.
# 4  
Old 01-22-2004
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
# 5  
Old 01-23-2004
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How make parent to wait from child process?

Hi all, I am starting mgen5 for sometime depends on input from a file, in a child process. now I want to make parent to wait in this child process till mgen5 finishes, or timeout happens. could anyone please tell me how to make parent to wait in child process in shell script? thanks... (2 Replies)
Discussion started by: girijajoshi
2 Replies

2. Shell Programming and Scripting

Script using Wait

Hi, written a script which uses wait as follows Main.sh #!/usr/bin/ksh nohup scrpit1 1 & pid_1=$! nohup scrpit1 2 & pid_2=$! wait $pid_1 wait $pid_2 nohup scrpit1 3 & pid_1=$! nohup scrpit1 4 & (1 Reply)
Discussion started by: krux_rap
1 Replies

3. Shell Programming and Scripting

calling a shell script in background and wait using "wait" in while loop

Hi, I am facing a strange issue, when i call a script from my while loop in background it doesnt go in background, despite the wait i put below the whil loop it goes forward even before the process put in background is completed. cat abc.txt | while read -u4 line do #if line contains #... (2 Replies)
Discussion started by: mihirvora16
2 Replies

4. Shell Programming and Scripting

Wait function in a script

Hi everyone, I need some help to create a script. This script have to create a file once all the process inside are finish. Here how I want to do : #!/bin/ksh /home/oracle/save1.ksh & proc_id1=$! /home/oracle/save2.ksh & proc_id2=$! /home/oracle/save3.ksh & proc_id3=$! ... (4 Replies)
Discussion started by: remfleyf
4 Replies

5. Shell Programming and Scripting

Make cron wait for the child process

I am trying to find a list of files and writing it to a text file. Based on the machine performance the file writing will be slow at certain time. The code to find file and redirecting the output to text file is on a shell script /usr/bin/find $SEARCH_DIR -daystart \( \( -name 'KI*' -a... (4 Replies)
Discussion started by: nuthalapati
4 Replies

6. Shell Programming and Scripting

How to make the parent process to wait for the child process

Hi All, I have two ksh script. 1st script calls the 2nd script and the second script calls an 'C' program. I want 1st script to wait until the 'C' program completes. I cant able to get the process id for the 'C' program (child process) to make the 1st script to wait for the second... (7 Replies)
Discussion started by: sennidurai
7 Replies

7. Programming

How can I make the parent thread wait

Hi All, I will be glad if you could help me resolve this problem. I have created two detachable threads and wanted to them execute independent of the parent thread ( the main task which creates the detachable threads). But I see no output coming from the execution of two detachable threads.... (4 Replies)
Discussion started by: jayfriend
4 Replies

8. Shell Programming and Scripting

To force a script to wait for another.

Hi All! Here is the problem, I'm trying to develop a script that can help me with the raid creation, but, till now, I have been dealing for more than a week and I still didn't achieve any satisfactory results. :confused: Here is the code to execute: # mdadm --manage /dev/md0 --add... (4 Replies)
Discussion started by: Ne7o7
4 Replies

9. UNIX for Advanced & Expert Users

how to make a parent wait on a child shells running in background?

Hi I have a shell script A which calls another 10 shell scripts which run in background. How do i make the parent script wait for the child scripts complete, or in other words, i must be able to do a grep of parent script to find out if the child scripts are still running. My Code: ... (1 Reply)
Discussion started by: albertashish
1 Replies

10. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies
Login or Register to Ask a Question