Return code for parallel running threads


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Return code for parallel running threads
# 1  
Old 05-11-2009
Return code for parallel running threads

Hi,

How to use the return code, for parallel running threads.

Ex-

grep pattern1 file1 file2 file3 file4 &
grep pattern1 file5 file6 file7 file8 &
grep pattern1 file9 file10 file11 file12 &

return_code=$?
if (return_code -eq 0)
then
echo "pattern found"
else
echo "pattern not found"
fi

Here, in this above samples of code, how to use return codes effectively, for the concurrent running greps, so that, i can get correct result for, "pattern1" is found in which grep.

It seems that, I need to use the thread locking and unlocking principle here. However, i am a bit confused, how to use this concept over here.

Please help.

Please indicate, if you need any further clarification of the problem.

Thanks and Regards,

Jitendriya Dash.
# 2  
Old 05-13-2009
You really cannot. You can get the return code for the most-recently launched and most-recently exited. What I don't understand, however, is that when you provide grep with more than one file name, it will print out the filename for each matching line. Why can't you rely on this feature?
# 3  
Old 05-13-2009
Code:
grep pattern1 file[1-12] &

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running script in Parallel

Hi Folks I have a doubt. I have a script which is running with 2 input parameters ./GetDSLnkCount.sh <jobnumber> Parmfile.txt I need to run the script in parallel for different jobnumbers. The commands are ./GetDSLnkCount.sh jnhuc14500 Parmfile.txt ./GetDSLnkCount.sh jnhuc14501... (3 Replies)
Discussion started by: morbid_angel
3 Replies

2. Shell Programming and Scripting

[Solved] Running scripts in parallel

i have script A and script B, both scripts have to run in parallel, my requirement is script A create table temp1, post creating it will run fr 4 hrs , script B has to start 0nly after creation of table temp1 ( which is done by script A) , again script B will run for 5 hrs if i run sequencially... (7 Replies)
Discussion started by: only4satish
7 Replies

3. UNIX for Dummies Questions & Answers

Running parallel process

i am having 4 process,have to run parallel and not after one by one. sample1.sh sample2.sh sample3.sh sample4.sh Thanks in advance. i (11 Replies)
Discussion started by: sagar_1986
11 Replies

4. Shell Programming and Scripting

Running uniq -c and sort -nr in parallel.

Hi All, I have a huge collection of files in a directory about 200000. I have the command below but it only uses one core of the computer. I want it to do task in parallel. This is the command that I want to run in parallel: sort testfile | uniq -c | sort -nr I know how to run sort... (10 Replies)
Discussion started by: shoaibjameel123
10 Replies

5. Shell Programming and Scripting

Running jobs in parallel

I need to process 50 sqlplus scripts which are listed in a text file. I need to develop a shell script that'll read this file and run these sqlplus scripts. At any point of time, the number of sqlplus scripts running shouldn't exceed 6. If any of the sqlplus scripts completes successfully then... (17 Replies)
Discussion started by: gctex
17 Replies

6. Programming

Modifying sniffex.c to include concepts of parallel programming or threads

HI For the past 1 week i have been trying to include the concepts of parallel programming or thread in the sniffex.c code. Haven't been able to.. Please suggest sm appropriate modifications to the following code: /* * sniffex.c * * Sniffer example of TCP/IP packet capture using... (1 Reply)
Discussion started by: aka.bhagvanji
1 Replies

7. Solaris

Number of threads running

Is there any command to find 1) the number of threads running 2) kernel boot mode in solaris box (2 Replies)
Discussion started by: vickylife
2 Replies

8. IP Networking

running servers parallel

I'm going to undertake a hardware refresh soon and I was wondering if it is possible to run two machines (X and Y) with the same hostname (but different IP addresses) on the same network? Server X is the original server and has an entry in DNS. Server Y is the new server and won't have an entry... (1 Reply)
Discussion started by: soliberus
1 Replies

9. Shell Programming and Scripting

Running scripts in parallel

Hi, Iam having the scripts as follows. i jus want to run those in parallel. main aim is to minimise the time for overall execution of the script. now out.txt is having 1 lac records. script1(split.sh) split -1000 out.txt splitout ls -A splitout* > filelist.txt cat filelist.txt... (6 Replies)
Discussion started by: nivas
6 Replies

10. Programming

running a parallel program

hi , i need to run a parallel program . for example; program1 { array=" the second program should called here : program 2" the execution should continue } the 2nd program should recieve an array of information as argument and it should... (4 Replies)
Discussion started by: bankpro
4 Replies
Login or Register to Ask a Question