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 302588630 by Corona688 on Monday 9th of January 2012 02:09:35 PM
Old 01-09-2012
Hmm. Like you say, the tricky bit is saving it. Thinking on something.

---------- Post updated at 01:09 PM ---------- Previous update was at 12:47 PM ----------

This mockup works for me:

Code:
#!/bin/sh

function fail
{
        printf "Should $1 succeed? "
        read VAR
        [ "$VAR" == "y" ] && return 0
        return 1
}

if [ -f .faillist ]
then
        set -- `cat .faillist`
        echo "Files succeeded:  `cat .succlist`"
        echo "Files remaining:  $*"
        echo "$1 failed previously."
        echo

        while [ "$VAR" != "r" -a "$VAR" != "s" -a "$VAR" != "q" ]
        do
                printf " Resume, Start Over, Quit [r/s/q]: "
                read VAR
        done
fi

case "$VAR" in
r)                      ;;      # Change nothing, everything's ready
q)      exit 1          ;;
s)      rm  -f .faillist .succlist
        set -- *.xml
        ;;
*)      set -- *.xml    ;;
esac

while [ "$#" -gt 0 ]
do
        echo "$@" > .faillist
        if ! fail "$1"
        then
                echo "Error in $1"
                echo "Aborting"
                exit 1
        fi

        printf " %s" "$1" >> .succlist
        shift
done

echo "Files succeeded:  `cat .succlist`"

rm .faillist
rm .succlist

It looks for xml files in the current directory but can be changed to look for them anywhere. It uses two files to record what succeeded and what failed.

Replace the 'fail' function with whatever you want to do to process these xml files. If you don't make it a function, you don't even need bash or ksh, nearly any sh should do.
This User Gave Thanks to Corona688 For This Post:
 

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
platform::shell(n)					       Tcl Bundled Packages						platform::shell(n)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(n)
All times are GMT -4. The time now is 07:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy