Sponsored Content
Top Forums Shell Programming and Scripting Executing a batch of files within a shell script with option to refire the individual files in batch Post 302588616 by goddevil on Monday 9th of January 2012 12:58:22 PM
Old 01-09-2012
Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below.

I am on a solaris server btw.

Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose.

Code:
 
#!/usr/bin/bash
./xmlprocshell.sh file1_import.xml    # This script accepts an XML file as an argument and performs different tasks and writes the result to an answerfile
./xmlparse.sh file1_import_answer.xml # This script parses the xml answer file and prints the results and ERRORS if any.
a=`printf 'cat //Guiroot/Errors/Errorcount/text()'| xmllint --shell file1_import_answer.xml | sed -n 2p` #extract the errorcount from the answer file
echo "THERE ARE $a ERRORS IN EXECUTION"
if [ $a -gt 0 ] ; then
exit
else
echo "execution successful"
fi
 
./xmlprocshell.sh file2_import.xml    
./xmlparse.sh file2_import_answer.xml
b=`printf 'cat //Guiroot/Errors/Errorcount/text()'| xmllint --shell file2_import_answer.xml | sed -n 2p`
echo "THERE ARE $b ERRORS IN EXECUTION"
if [ $b -gt 0 ] ; then
exit
else
echo "execution successful"
fi
.
.
#And so on

There are over 50 of these xml files that needs to be executed by the shell. If there are errors in execution of an xml file, the shell script should exit and the error will need to be fixed.

The tricky part is: once the error is fixed, the script should present the user with an option to resume the execution from the xml file that failed or execute all the files from the beginning.

How do i go about designing a script that will do the following:
1. Present the user with a list of 50 files to run.
2. Any option that the user chooses should pass the file as an argument to the xmlprocshell.sh which do do the deed.
3. If the execution is successful the next file in the order is executed automatically and so on.

Do i put the above inside a function and pass the files as arguments or do i go with loops. If anyone can provide me with an example template, i'd be extremely grateful. Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting Shell script to Dos batch files

Hi friends! I am having some simple shell script files to build postgresql database and all. Now i want to convert those scripts to dos batch scripts(to run on windows XP/2000/NT) because there is no need of unix emulation for latest release of postgresql. Please somebody help me. (1 Reply)
Discussion started by: darwinkna
1 Replies

2. Shell Programming and Scripting

bash - batch script for extracting one file from multiple tar files

so i have hundreds of files named history.20071112.tar (history.YYYYMMDD.tar) and im looking to extract one file out of each archive called status_YYYYMMDDHH:MM.lis here is what i have so far: for FILE in `cat dirlist` do tar xvf $FILE ./status_* done dirlist is a text... (4 Replies)
Discussion started by: kuliksco
4 Replies

3. Shell Programming and Scripting

batch shell script to zip individual files in directory - help

help trying to figure out a batch shell script to zip each file in a directory into its own zip file using this code but it does not work tryed this also nothing seems to work , just ends without zipping any files i have over 3000 files i need to zip up individualy ... (7 Replies)
Discussion started by: wingchun22
7 Replies

4. UNIX for Dummies Questions & Answers

Permissions to files using batch script.

Hi all, I am using a batch script that ftps the compressed xml files to the Unix environment from the Windows environment and i perform this using the below line of coding: echo cd %VAR_TR_FTP_DIR% > %TR_FTP_BATCH_FILE BatchNum% Echo lcd "%VAR_TR_SOURCE_PATH_BatchNum%">> %TR_FTP_BATCH_FILE... (1 Reply)
Discussion started by: Codesearcher
1 Replies

5. UNIX for Dummies Questions & Answers

Batch Renaming of Files

Hello all, thanks for your time (and this forum, what an awesome resource for newbs like myself!) Anyways, I've been given the task of importing content from a directory of about...7000 HTML files. They are all named appropriately and broken down by name depending on what book they belong too.... (8 Replies)
Discussion started by: gratefulhokie
8 Replies

6. Shell Programming and Scripting

script for renaming a batch of files

hi i have a folder full of files. some of the names are quite off because the dimensions were the same and i had to put a 'b' after the initial number so that it didnt overwrite. what i want is a script in unix to overwrite the filwe name leaving some of the title intact, e.g. below are some... (3 Replies)
Discussion started by: shabs1985
3 Replies

7. Shell Programming and Scripting

Need to exclude .NFSxxx files in clear old files batch script

I am new to Shell Scripting and need some help. The following batch job has been failing for me due to the .nfsxxx files in use. I need to know how to modify the following script to exclude the .nfsxxx files so this batch job will not fail on me. I have done lots of googling and keep coming back... (2 Replies)
Discussion started by: kimberlyg2007
2 Replies

8. Shell Programming and Scripting

Accessing files in batch

hai, I have a list of files having extension .sy in a folder. I want to find such files and print the first two columns of the files to new extension .tmp (1 Reply)
Discussion started by: sreejithalokkan
1 Replies

9. Shell Programming and Scripting

Need help in batch renaming files with bash shell script.

I have some 50+ files in the following format : abcd_vish_running_ZEBRA_20140818.dat_08-14-2014_23:08:23 abcd_vish_running_ZEB-RA_20140818.dat_08-14-2014_23:08:35 abcd_vish_running_ZEB_RA_20140818.dat_08-14-2014_23:08:37 abcd_vish_running_RI-NG_20140818.dat_08-14-2014_23:08:42... (5 Replies)
Discussion started by: SriRamKrish
5 Replies

10. UNIX for Beginners Questions & Answers

Batch processing files through an interactive script

I am newish to the site and to unix. I have a functioning interactive script running on Mac that sorts and processes files located in an unsorted folder on my desktop. As it currently stands, the user types jpg into the command line, the script executes and iterates through the unsorted... (8 Replies)
Discussion started by: Braveheart
8 Replies
PACEMAKER(8)						  System Administration Utilities					      PACEMAKER(8)

NAME
Pacemaker - Part of the Pacemaker cluster resource manager SYNOPSIS
crm_diff original_xml operation [options] DESCRIPTION
crm_diff - A utility for comparing Pacemaker configurations (XML format) The tool produces a custom (diff-like) output which it can also apply like a patch OPTIONS
-?, --help This text -$, --version Version information -V, --verbose Increase debug output Original XML: -o, --original=value XML is contained in the named file -O, --original-string=value XML is contained in the supplied string Operation: -n, --new=value Compare the original XML to the contents of the named file -N, --new-string=value Compare the original XML to the contents of the supplied string -p, --patch=value Patch the original XML with the contents of the named file Additional Options: -c, --cib Compare/patch the inputs as a CIB (includes versions details) -f, --filter Suppress irrelevant differences between the two inputs EXAMPLES
Obtain the two different configuration files by running cibadmin on the two cluster setups to compare: # cibadmin --query > cib-old.xml # cibadmin --query > cib-new.xml Calculate and save the difference between the two files: # crm_diff --original cib-old.xml --new cib-new.xml > patch.xml Apply the patch to the original file: # crm_diff --original cib-old.xml --patch patch.xml > updated.xml Apply the patch to the running cluster: # cibadmin --patch patch.xml AUTHOR
Written by Andrew Beekhof REPORTING BUGS
Report bugs to pacemaker@oss.clusterlabs.org Pacemaker 1.1.7 April 2012 PACEMAKER(8)
All times are GMT -4. The time now is 09:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy