08-01-2006
Need to execute 2 scripts, wait, execute 2 more wait, till end of file
I need to execute a shell script to do the following:
cat a file
run two back ground processes using the first two values from the file
wait till those background processes finish
run two more background processes using the next two values from the file
wait till those background processes finish
etc till the end of the file.
Can anyone give me a way to do this? I cannot run all of the background processes at the same time, I can only do two at time.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi All,
Since I want to execute TCL scripts in HP-UX, I cannot find where to start. I try to execute the following scripts. It gets "tclsh: not found." errors.
Where / how to execute tcl scripts? Thanks a lots.
#!/bin/sh
# the next line restarts using wish \
exec tclsh "$0" "$@" (3 Replies)
Discussion started by: wilsonchan1000
3 Replies
2. Shell Programming and Scripting
Hi
I am creating 3 background processes in my shell script using &.
I have obtained the 3 PIDs of the background processes using $!.
I need to wait for these to complete and i need the exit status of each of these.
If i use :
wait $PID1
wait $PID2
wait $PID3
and get the exit status of... (1 Reply)
Discussion started by: Vinaya
1 Replies
3. Shell Programming and Scripting
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
4. UNIX for Dummies Questions & Answers
Hello All,
i am a newbie and need some help when reading a csv file in a bourne shell script. I want to read 10 lines, then wait for a minute and then do a reading of another 10 lines and so on in the same way. I want to do this till the end of file.
Any inputs are appreciated
... (3 Replies)
Discussion started by: victor.s
3 Replies
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good.
I appreciate... (3 Replies)
Discussion started by: wolf@=NK
3 Replies
7. Shell Programming and Scripting
Hi All, i have a requirement
I created a file list as below :
more abc_file_list.txt
Rem_DD.csv
Rem_Non.csv
Rem_Ld.csv
CC_Ld_Non_IRA.csv ...
Above are the 4 files (For now ,we dont know how many in the file) which need to be present else need to get an email for missing files.
... (3 Replies)
Discussion started by: dssyadav
3 Replies
8. Programming
Hi,
How to wait the slave to be finished first then execute the master?
Can someone give me the specific function? Or the detailed example.
Thanks~ (1 Reply)
Discussion started by: wanliushao
1 Replies
9. AIX
Hi,
I am really sorry for this question but still i am confused.
I have shell script called sample.sh
I can execute only with the combination of ./sample.sh
Is ./ really necessary ? Is it something related with $HOME or $PATH variable.
Why and How can i resolve this case ?
... (2 Replies)
Discussion started by: Nandy
2 Replies
10. UNIX for Beginners Questions & Answers
Hi
I am facing a problem in my ksh.
My main script is calling 3 different child process in the background.
I am using wait to finish all and then submit another 3 child processes.
Now what i want is , whenever any one child process finishes ,i want to submit next one.so that parallel 3... (2 Replies)
Discussion started by: Sangu
2 Replies
LEARN ABOUT CENTOS
tcl_detachpids
Tcl_DetachPids(3) Tcl Library Procedures Tcl_DetachPids(3)
__________________________________________________________________________________________________________________________________________________
NAME
Tcl_DetachPids, Tcl_ReapDetachedProcs, Tcl_WaitPid - manage child processes in background
SYNOPSIS
#include <tcl.h>
Tcl_DetachPids(numPids, pidPtr)
Tcl_ReapDetachedProcs()
Tcl_Pid
Tcl_WaitPid(pid, statusPtr, options)
ARGUMENTS
int numPids (in) Number of process ids contained in the array pointed to by pidPtr.
int *pidPtr (in) Address of array containing numPids process ids.
Tcl_Pid pid (in) The id of the process (pipe) to wait for.
int *statusPtr (out) The result of waiting on a process (pipe). Either 0 or ECHILD.
int options (in) The options controlling the wait. WNOHANG specifies not to wait when checking the process.
_________________________________________________________________
DESCRIPTION
Tcl_DetachPids and Tcl_ReapDetachedProcs provide a mechanism for managing subprocesses that are running in background. These procedures
are needed because the parent of a process must eventually invoke the waitpid kernel call (or one of a few other similar kernel calls) to
wait for the child to exit. Until the parent waits for the child, the child's state cannot be completely reclaimed by the system. If a
parent continually creates children and doesn't wait on them, the system's process table will eventually overflow, even if all the children
have exited.
Tcl_DetachPids may be called to ask Tcl to take responsibility for one or more processes whose process ids are contained in the pidPtr
array passed as argument. The caller presumably has started these processes running in background and does not want to have to deal with
them again.
Tcl_ReapDetachedProcs invokes the waitpid kernel call on each of the background processes so that its state can be cleaned up if it has
exited. If the process has not exited yet, Tcl_ReapDetachedProcs does not wait for it to exit; it will check again the next time it is
invoked. Tcl automatically calls Tcl_ReapDetachedProcs each time the exec command is executed, so in most cases it is not necessary for
any code outside of Tcl to invoke Tcl_ReapDetachedProcs. However, if you call Tcl_DetachPids in situations where the exec command may
never get executed, you may wish to call Tcl_ReapDetachedProcs from time to time so that background processes can be cleaned up.
Tcl_WaitPid is a thin wrapper around the facilities provided by the operating system to wait on the end of a spawned process and to check a
whether spawned process is still running. It is used by Tcl_ReapDetachedProcs and the channel system to portably access the operating sys-
tem.
KEYWORDS
background, child, detach, process, wait
Tcl Tcl_DetachPids(3)