[Solved] Running scripts in parallel that issue prompt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Running scripts in parallel that issue prompt
# 1  
Old 09-17-2012
[Solved] Running scripts in parallel that issue prompt

Hi all - I am totally stuck here :wall
I have been asked to write a shell script that does a few little things and then reads from a config file and kicks off an instance of another script, say scriptB.ksh for each line in the config file. These should all be run in parallel. This is all fine but scriptB.ksh prompts the user to confirm they want to proceed. I thought I had this handled with a here document but the problem is the instances of scriptB.ksh don't run in parallel then anymore. I do not own scriptB.ksh, its a shared script, I cannot change it, I cannot clone it...bottom line I have to work with it somehow.
Here is (one version!) what I have so far though I have experimented with moving the & around etc:

Code:
#!/usr/bin/ksh

IFS='|'
set -o xtrace

CONFIG=/home/testing/release.config

while read varA varB varC varD varE
do
        LOGFILE=release_`echo $varA`_`echo $varB`_`date '+%d%y%m_%H%M'`.log
        scriptB.ksh -j$varA -v$varB -i$varC -S$varD -D$varE <<!
c
!
> $LOGFILE 2>&1 &
        PIDS=$PIDS" "$!
done <"$CONFIG"

wait $PIDS

Would really appreciate any help - I am so long looking at it now I can't see any fresh leads!

Last edited by sjmolloy; 09-17-2012 at 04:20 AM..
# 2  
Old 09-17-2012
Try..

Code:
while read varA varB varC varD varE
do
        LOGFILE=release_`echo $varA`_`echo $varB`_`date '+%d%y%m_%H%M'`.log
        scriptB.ksh -j$varA -v$varB -i$varC -S$varD -D$varE << ALWAYS_SAFE  > $LOGFILE 2>&1 &
	c
ALWAYS_SAFE
	PIDS=$PIDS" "$!
done <"$CONFIG"

You can use the "dashed" label to indent the heredoc (ONLY with tabs and NOT spaces).

like


Code:
while read varA varB varC varD varE
do
        LOGFILE=release_`echo $varA`_`echo $varB`_`date '+%d%y%m_%H%M'`.log
        scriptB.ksh -j$varA -v$varB -i$varC -S$varD -D$varE <<-ALWAYS_SAFE  > $LOGFILE 2>&1 &
	c
	ALWAYS_SAFE
	PIDS=$PIDS" "$!
done <"$CONFIG"


Also, by default, wait without any argument, would wait for all the background jobs.
This User Gave Thanks to clx For This Post:
# 3  
Old 09-17-2012
clx - thank you so much! I was totally overthining it and as a result was never going to find a result. Tested and running away in production as we speak - thank you, thank you, thank you!

BTW, reason I am passing pids to wait is that I kick off another (continuous) process in the background at the start of the script and I want it to run until all the scriptB processes are finished and then I kill it. As a result if I don't pass pids the continuous process would be included and the wait would never return.
I was just trying to cut down the sample code.
This User Gave Thanks to sjmolloy For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parallel bash scripts

Need some help to replace bash script with parallel to speed up job on multiple files (400files.list is the file contains the absolute path to those 400 files). The bash script is to run the same program over the files repetitively. My bash_script.sh is: for sample in `cat 400files.list`; do... (3 Replies)
Discussion started by: yifangt
3 Replies

2. Shell Programming and Scripting

Issue with SUNOS running sed scripts

Hi I probably dont have GNU extended sed in my SUNOS . and its creating lot of problems ex: a simple sed command like this is not working sed '/WORD/ a\ sample text line 1 \ sample text line 1 ' filename sed: command garbled: /WORD/ a I took precaution to have a new line after... (11 Replies)
Discussion started by: vash
11 Replies

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

4. UNIX for Dummies Questions & Answers

[Solved] Variable Name as a Prompt

Dear Members, I have an variable by name dir.If i do echo $dir i will get the path (/usr/bin/). I am writing a shell script which will prompt to enter the variable name if run.Suppose the script name is test.sh. If run test.sh it will prompt for entering variable name which is dir.Suppose... (9 Replies)
Discussion started by: sandeep_1105
9 Replies

5. Shell Programming and Scripting

Execute scripts in Parallel

Hi I want to execute few scripts in Parallel. There is a Master Script (MS.ksh) which will call internally all the scripts we need to run in Parallel. Say there are three set of scripts : ABC_1.ksh --> ABC_2.ksh --> ABC_3.ksh (execute ABC_2 when ABC_1 is successful ; Execute ABC_3 only when... (6 Replies)
Discussion started by: dashing201
6 Replies

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

7. Shell Programming and Scripting

Executing scripts in Parallel

Hi All, I have 3 shell scripts, Script1,Script2 and Script3. Now I want to run Script1 and Script2 in parallel and Script3 should depend on successful completion of both Script1 and Script2. Could you please suggest an approach of acheiving this... Thanks in advance (2 Replies)
Discussion started by: itsme_maverick
2 Replies

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

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

10. Shell Programming and Scripting

SQL scripts not running, possible timeout issue?

I am a novice Unix scripter and need a little advice/help on a script I've written that's causing some problems. We are using Solaris 9 on a Sun box and the script is invoked with the korn shell. I have a two-part question: I wrote a shell script that calls and executes 3 separate sql scripts,... (3 Replies)
Discussion started by: E2004
3 Replies
Login or Register to Ask a Question