The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Running scripts in parallel nivas Shell Programming and Scripting 6 02-21-2008 05:44 AM
executing scripts by reading names from a file konark Shell Programming and Scripting 3 11-08-2007 02:28 AM
Executing Shell Scripts BuyoCat UNIX for Dummies Questions & Answers 1 09-07-2005 02:11 AM
executing variables in ksh scripts? zedmelon Shell Programming and Scripting 3 08-06-2003 02:50 PM
executing perl scripts vtran4270 UNIX for Advanced & Expert Users 2 08-27-2002 03:28 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-05-2008
itsme_maverick itsme_maverick is offline
Registered User
  
 

Join Date: May 2008
Posts: 5
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 (permalink)  
Old 06-05-2008
fabtagon fabtagon is offline
Registered User
  
 

Join Date: Apr 2008
Location: European Union/Germany
Posts: 189
simple polling approach (this master script itself may not run parallel, vulnerable to symlink attacks through unsafe tmp file creation, ...)

Code:
#!/bin/bash
# should work in most shells
(script1; echo $? > /tmp/retval1 ) &
script2
# both do now run in parallel
# ...
# well, after some time script2 will have finished, so well have to check whether 2 also has
retval2=$?
while [ $? -eq 0 ]
do
  sleep 1s
  pidof script1 > /dev/null
done
retval1=`cat /tmp/retval1`
if [ something about retval1 and retval2 ]
then
  script3
fi


Last edited by fabtagon; 06-05-2008 at 05:47 PM.. Reason: missed one point
  #3 (permalink)  
Old 06-06-2008
itsme_maverick itsme_maverick is offline
Registered User
  
 

Join Date: May 2008
Posts: 5
Quote:
Originally Posted by fabtagon View Post
simple polling approach (this master script itself may not run parallel, vulnerable to symlink attacks through unsafe tmp file creation, ...)

Code:
#!/bin/bash
# should work in most shells
(script1; echo $? > /tmp/retval1 ) &
script2
# both do now run in parallel
# ...
# well, after some time script2 will have finished, so well have to check whether 2 also has
retval2=$?
while [ $? -eq 0 ]
do
  sleep 1s
  pidof script1 > /dev/null
done
retval1=`cat /tmp/retval1`
if [ something about retval1 and retval2 ]
then
  script3
fi

What does the line in "while loop" do ? pidof script1 > /dev/null
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0