Run a script parallely with different arguments


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run a script parallely with different arguments
# 1  
Old 02-12-2010
Run a script parallely with different arguments

Hi!
I want to run a script in parallel with different arguments.

eg.

start
script.sh argA script.sh argB script.sh argC
end

Can someone please tell how to achieve this.
Thanks in advance.
# 2  
Old 02-13-2010
Code:
script.sh argA &
script.sh argB &
script.sh argC &

# 3  
Old 02-14-2010
Thank you very much!
# 4  
Old 02-14-2010
you can
Code:
for ARG in argA argB argC
do
    script.sh $ARG &
done

or
Code:
for ARG in A B C
do
    script.sh arg$ARG &
done

too
# 5  
Old 02-15-2010
It is good practise to issue a wait statement after the start of all the background processes to stop the parent shell from exiting before all of its children have finished.
Code:
for ARG in argA argB argC 
do
    script.sh $ARG &
done
wait

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run multiple procedures from shell script parallely

Hi, I need to write a Shell Script wherein i will connect to a DB2 Database and run multiple DB procedures. I know how to do in a way where procedures will be called one after the other, like when first procedure finishes, second will be executed. But what i want is to run them at the same time... (11 Replies)
Discussion started by: Neelkanth
11 Replies

2. Shell Programming and Scripting

How to run scripts parallely inside shell script?

Hi , I have 4 scripts example script1,script2,script3,script4 . I have to run script1,script2 and script3 parallely since this 3 scripts dont have dependencies . Once script1,script2 and script3 got completed successfully , I have to trigger script4. Can someone help me on this how to... (10 Replies)
Discussion started by: vinothsekark
10 Replies

3. Shell Programming and Scripting

To run a local shell script in a remote machine by passing arguments to the local shell script

I need to run a local shell script on a remote machine. I am able to achieve that by executing the command > ssh -qtt user@host < test.sh However, when I try to pass arguments to test.sh it fails. Any pointers would be appreciated. (7 Replies)
Discussion started by: Sree10
7 Replies

4. Shell Programming and Scripting

Passing multiple run time arguments

the scenario is - If I pass 3 three arguments( run time) , it should list all .txt files from a path to temp file if I pass 2 arguments ( run time) , it should list all .csv files from the same path to another temp file the above scenario should be handled in single code and also I dont know ... (2 Replies)
Discussion started by: Prashanth B
2 Replies

5. Shell Programming and Scripting

php file unable to run shell script with arguments

echo $result=exec("./permit.sh".$_FILES); pls suggest some other method to run shell script in php .:wall::mad: (0 Replies)
Discussion started by: upvan111
0 Replies

6. UNIX and Linux Applications

how to run more than two processes parallely

I would like to call a function called CIRCLE which is further beind called by other function but in a loop that CIRCLE fuction is being called. And this CIRCLE function starts another process which takes 3 hours to complete again, if i put that process in nohup &, I can go to the next command... (2 Replies)
Discussion started by: venugopalsmartb
2 Replies

7. Shell Programming and Scripting

compare parallely

hi, i have folder backup and it contains 3 sub-directories , i want to compare /backup/1 with /recover/1 and /backup/2 with /recover/2 etc . parallelly with using shell scripting . pls help me thanks (2 Replies)
Discussion started by: shankr3
2 Replies

8. Shell Programming and Scripting

Run perl script with multiple file arguments

Hello everyone, I have two types of files in a directory: *.txt *.info I have a perl script that uses these two files as arguments, and produces a result file: perl myScript.pl abc.txt abc.xml How can I run this script (in a "for" loop , looping through both types of files)... (4 Replies)
Discussion started by: ad23
4 Replies

9. Shell Programming and Scripting

Multiple Threads/Tasks to run parallely using the shell script

Scenario: I have two PCs (named as A & B) which would send some traps to my third PC (named as C). In PC C, I have to write a shell script such that it should accept the datas from both the PC-A & B parallely. So my question is, is it possible to have two different child threads/tasks... (2 Replies)
Discussion started by: nthiruvenkatam
2 Replies

10. UNIX for Dummies Questions & Answers

Help how replace stardard keyboard inputs by arguments at run time of a script

Hello Everybody, Please help. I was trying to automate the use of a third-party given shell script. The script is written to be used at run-time to collect a few variables to be provided by the user through key board, in the fashion as below: ./runcommand please provide a file name to... (6 Replies)
Discussion started by: Dingrong
6 Replies
Login or Register to Ask a Question