Sponsored Content
Top Forums Shell Programming and Scripting calling a shell script in background and wait using "wait" in while loop Post 302584849 by mihirvora16 on Monday 26th of December 2011 06:53:49 AM
Old 12-26-2011
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.

Code:
cat abc.txt | while read -u4 line
do
   #if line contains # dont proces that line and continue to next line
   echo $line | grep '#' > /dev/null
   if [[ $? -eq 0 ]]; then
        echo ...skipping comment
        continue
   fi
   # extracting the values from cfg file
   username=`echo $line | cut -d" " -f1`
   hostname=`echo $line | cut -d" " -f2`
   dir=`echo $line | cut -d" " -f3`
   type=`echo $line | cut -d" " -f4`
   dmnname=`echo $line | cut -d" " -f5`
   mnserver=`echo $line | cut -d" " -f6`
   . ${TOOL_DIR}/formatReport.sh $hostname $dmnname $mnserver $curhour $type $reportdir $dir $curdate &
   echo "Process ID = $!"
done
wait
#further processing

file contents for abc.txt
Code:
abc  sun1  /prod/var/1  web1    web_43_1   mt_027_9043_1
def  sun2  /prod/var/2  web2    web_43_2   mt_027_9043_2
pqr  sun3  /prod/var/3  web3    web_43_3   mt_027_9043_3

---------- Post updated at 06:23 PM ---------- Previous update was at 06:14 PM ----------

Any help will be appreciated.. Guys any pointers to what can be issue?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to include RETURN KEY with Background process "&" in Shell Script

Hello All, I am a newbie in Shell script programming, and maybe you can help me with my query. I need to write a shell script (mntServer.ksh) that will start a background process and also to be able to run another script. The mntServer.ksh script contains: #!/bin/ksh... (1 Reply)
Discussion started by: racbern
1 Replies

2. 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

3. Shell Programming and Scripting

wait in background

can a wait command be run in background? or the script which has the wait command, be run background? test.sh ------- nohup a.sh & nohup b.sh & wait nohup test.sh & How can i run either wait or test.sh in background? i want test.sh to wait till a.sh and b.sh complete, and must be... (1 Reply)
Discussion started by: albertashish
1 Replies

4. Shell Programming and Scripting

Don't wait for "read line"

Hi I am writing a bash script on Solaris, that should take n arguments, either appended to the script or taken as output from the last command (similar to grep). What I don't want is that the script waits for user input. In other words: Possibility 1: script.sh arg1 arg2 arg3 ...Possibility... (4 Replies)
Discussion started by: g000ze
4 Replies

5. UNIX for Dummies Questions & Answers

Do pipes know when they have to "wait" for all the data?

Hi, I was wondering if pipes ("|"), or rather the command that follow them, know when they're supposed to wait for all the data? For instance, if you take this: cat my_file | sort | uniq for uniq to work well, it needs to have rows sorted, but for lines to be sorted properly, it needs... (5 Replies)
Discussion started by: a.brassac
5 Replies

6. HP-UX

echo "selall;info;wait;infolog" | /usr/sbin/cstm problem

Hello, On a HP-UX 10.20 server I've executed something similar to this command: # echo 'selall;info;wait;infolog;view;done' | /usr/sbin/cstm But it returns sometype of "argument list too long" error. I suppose there is a way to fix it by using xargs but I can't figure it out. Any... (7 Replies)
Discussion started by: asanchez
7 Replies

7. Shell Programming and Scripting

How to increment date using "for loop" in format MMDDYY inside the shell script?

Need to increment the date from "currentdate + 90days" inside the for loop (i=1 to i=50) (5 Replies)
Discussion started by: aroragaurav.84
5 Replies

8. AIX

How to use 'expect' to pass UID & Password to a "for loop" in shell script?

Friends, Need someone's help in helping me with the below requirement for a script: > For a list of servers(over 100+), I need to login into each of them(cannot configure password-less ssh) & grab few configuration details < I know, this is possible through expect programming in a simple... (2 Replies)
Discussion started by: thisissouvik
2 Replies

9. Shell Programming and Scripting

How to use 'expect' to pass UID & Password to a "for loop" in shell script?

Friends, Need someone's help in helping me with the below requirement for a script: > For a list of servers(over 100+), I need to login into each of them(cannot configure password-less ssh) & grab few configuration details < I know, this is possible through expect programming in a simple... (14 Replies)
Discussion started by: thisissouvik
14 Replies

10. UNIX for Dummies Questions & Answers

When loading Linux "loading please wait.." then nothing?

Hi everyone, I have a problem but I have never installed a separate OS before so my lingo and understanding may not be as good as some of you. I will try and explain my problem best I can. I am trying to instead of loading Windows 7 when my computer starts up, for it to start linux specifically... (2 Replies)
Discussion started by: markhow30
2 Replies
BOOLVAL(3)								 1								BOOLVAL(3)

boolval - Get the boolean value of a variable

SYNOPSIS
boolean boolval (mixed $var) DESCRIPTION
Returns the boolean value of $var. PARAMETERS
o $var - The scalar value being converted to a boolean. RETURN VALUES
The boolean value of $var. EXAMPLES
Example #1 boolval(3) examples <?php echo '0: '.(boolval(0) ? 'true' : 'false')." "; echo '42: '.(boolval(42) ? 'true' : 'false')." "; echo '0.0: '.(boolval(0.0) ? 'true' : 'false')." "; echo '4.2: '.(boolval(4.2) ? 'true' : 'false')." "; echo '"": '.(boolval("") ? 'true' : 'false')." "; echo '"string": '.(boolval("string") ? 'true' : 'false')." "; echo '"0": '.(boolval("0") ? 'true' : 'false')." "; echo '"1": '.(boolval("1") ? 'true' : 'false')." "; echo '[1, 2]: '.(boolval([1, 2]) ? 'true' : 'false')." "; echo '[]: '.(boolval([]) ? 'true' : 'false')." "; echo 'stdClass: '.(boolval(new stdClass) ? 'true' : 'false')." "; ?> The above example will output: 0: false 42: true 0.0: false 4.2: true "": false "string": true "0": false "1": true [1, 2]: true []: false stdClass: true SEE ALSO
floatval(3), intval(3), strval(3), settype(3), is_bool(3), Type juggling. PHP Documentation Group BOOLVAL(3)
All times are GMT -4. The time now is 09:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy