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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to find Dependent libraries in ELF file? ravinder.are Filesystems, Disks and Memory 3 04-04-2008 06:23 AM
Dependent Object Framework 0.9 (Default branch) iBot Software Releases - RSS News 0 02-04-2008 09:10 PM
Script execution dependent upon a file landing in a certain directory keladar Shell Programming and Scripting 3 12-27-2007 07:19 PM
Editor dependent error? new2ss Shell Programming and Scripting 2 02-16-2006 11:18 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-08-2006
Registered User
 

Join Date: Jul 2006
Posts: 55
Job dependent on other job

Hi All

I am trying to run one command ie grep but I want it should execute only after the completion of a shell script has finished.

eg

Following is my script :

java -mx64m $JAVA_OPTS -Dant.home=$ANT_HOME -classpath $_CLASSPATH org.apache.tools.ant.Main -verbose -buildfile /opt/bea/wls
61/config/dev05/batch_automation/MBPSBatch/scripts/build.xml > /opt/bea/wls61/config/dev05/batch_automation/MassTransfer/lo
gs/ant.log 2>&1 &

grep -i "BUILD FAILED" /opt/bea/wls61/config/dev05/batch_automation/MassTransfer/logs/ant.log 2>/dev/null
rcode=$? ############save the return code here if Failed found it would be 0
if [ $? -ne 0 ]
then
echo "No failed found run the script abc.sh"
. /opt/bea/wls61/config/dev05/batch_automation/MassTransfer/startMassTransfer.sh
else
echo "Failed encounter ..."
mailx -s "[`date`] Failure: Error in script" sdfgg@dgssg.com < /opt/bea/wls61/config/dev05/batch_automation/Mass
Transfer/logs/ant.log
echo "Error was encountered in your script" | mailx -s "ALERT!!" dsfhjkhdfsjh@dsfjhl.com
fi

Problem is even though no BUILD FAILED is encountered in ant.log still else part gets executed ie Failed encounter.

Please suggest some ways so that it works on the logic....... if build success ,should process if part , if failure should execute else part

Thanks

Pankaj
Reply With Quote
Forum Sponsor
  #2  
Old 09-08-2006
puspendu's Avatar
Registered User
 

Join Date: Jul 2004
Location: INDIA
Posts: 18
You are submitting the "java -mx64m $JAVA_OPTS..." as a background job. I think if you keep it as a foreground process then grep will be executed only after the "java -mx64m $JAVA_OPTS..." thing.

Plz try and check.

~PG
Reply With Quote
  #3  
Old 09-09-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,297
You can do the following
Code:
#choice 1
java &
wait
grep 
#choice 2
java <.....> && grep <..> &
# choice  if the java build returns a meaningful status code
$(status=$(java <... > && echo "OKAY")  
if [[ $status = "OKAY" ]] ; then
   echo "Success"
else
   echo "failure"
fi ) &
wait
Reply With Quote
  #4  
Old 09-09-2006
Registered User
 

Join Date: Jul 2006
Posts: 12
Can you check if your script failed atleast once? I mean you might be looking at the same old log file repeatedly. This is my guess. Try and let me know.
Reply With Quote
  #5  
Old 09-10-2006
Registered User
 

Join Date: Aug 2006
Posts: 122
Just user "wait"

Just ues the "wait" command inside your shell script or from command line

ie

java -metc etc etc >.../log.file &
wait
grep BUILD...... /log.file

The wait will wait until the back ground process completes before allowing the next command to be executed...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:25 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0