Sponsored Content
Top Forums Shell Programming and Scripting Help needed on wrapper script Post 302901037 by express14 on Sunday 11th of May 2014 02:16:45 AM
Old 05-11-2014
Help needed on wrapper script

Hi Gurus,

I need to build a wrapper script which will be passing the loading date and the data file name (provides option to the user to load a single data file or load all the data files) to the actual loader data_load.ksh to load in the database.

1. I want to execute the loader script data_load.ksh one after another (one at a time), that is once data_load.ksh File1 finishes data_load.ksh File2 will start so and so forth. Loading a single file is not a concern. For full/all data files load, I am reading the data file names from a text file 'file.list' and executing the data_load.ksh from a for loop with an ampersand (sending to the background) & wait signal for each file, hoping that wait command will meet my expectation. Is there any alternate way of doing this?

2. My date validate part is not quite working as expected. Technically 20141411 date format should be incorrect but according to my date validation check echo ${dt}|grep -E -q '^201[1-9][01][0-9][0-3][0-9]$' it shows correct. How can I fix the MM part, so that any number other than 1 to 12 determines incorrect format?

3. In my fn_SingleFileLoad function, file name is passed through the input prompt. The input can not be more than one file name (i.e the program should send error or exit if someone provides more than one file. Example of an input: FileA FileB). Can someone please share some expertise on this part?

I would like to thank you all in advance for sharing your suggestions or help here.

Code:
#!/bin/ksh

###function for a complete data load  (i.e. all data files loading into database)
fn_AllFileLoad()
	{
           echo "enter the loadings date in YYYYMMDD format: "
           read dt
         
           # validates the date format
           echo ${dt}|grep -E -q '^201[1-9][01][0-9][0-3][0-9]$'
               if [[ $? != 0 ]]; then
                  echo "========================================================================="
         	  echo "Please enter the date in YYYYMMDD format. Terminating...No action done..."
         	  exit 1
               else
            
            	 .${HOME}/dbscripts/set_date.ksh $dt &
            	
 		for i in `cat ${HOME}/dbscripts/file.list`
                    do
            	    .${HOME}/dbscripts/data_load.ksh $i &
                    done
	            wait
         	fi
 
         }

fn_SingleFileLoad()
	 {
            echo "Enter the file name to load"
            read file
            echo "enter the loadings date in YYYYMMDD format: "
            read dt
        
            # validates the date format
            echo ${dt}|grep -E -q '^201[1-9][01][0-9][0-3][0-9]$'
                if [[ $? != 0 ]]; then
                   echo "========================================================================="
         	   echo "Please enter the date in YYYYMMDD format. Terminating...No action done..."
         	   exit 0
         	else
            
            	.${HOME}/dbscripts/set_date.ksh $dt &
            	.${HOME}/dbscripts/data_load.ksh $file & 
		fi
        }
 

#Main program starts here....

echo "Do you want to run a complete load? [Y/N]"
read yn
option=$yn
case $option in 
   Y|y ) fn_AllFileLoad;;
   N|n ) fn_SingleFileLoad;;
   * ) echo "Please answer only 'Y/y' for yes or 'N/n' for no.....terminating"
   exit;;
 esac

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

What is wrapper script and how to write

hi guys, I have a requirement to run a script 4 times with different parameter values. the 4 jobs have to run parallely which actually access different data of same table and deletes. how can i achieve this.................? Thanks in advance (1 Reply)
Discussion started by: chiru
1 Replies

2. UNIX for Dummies Questions & Answers

What is a wrapper script

I tried searching the forum ,,but couldn't locate ..Can anyone give me a link or some information about wrapper script. (1 Reply)
Discussion started by: thana
1 Replies

3. Shell Programming and Scripting

Korn Shell Wrapper script

Hi Guys, I am trying write a wrapper script but I don't have any idea. I have 4 different korn shell scripts and all of them needs some parameters from command line (positional parameter). My script cant be interactive because its supposed to be automated. I am confused how can I write a wrapper... (6 Replies)
Discussion started by: pareshan
6 Replies

4. Shell Programming and Scripting

Help with a wrapper script not working

Hello, I have the below wrapper script: #!/usr/bin/perl -w if ($^O eq 'MSWin32' ) { $subnet = 'c:\path\to\subnet.txt'; } else { $subnet = '/opt/qip/wrapper-del-sub'; } open FH1, 'jj-deleted-subnets.txt' or die "Can't open 'jj-deleted-subnets.txt' ... (0 Replies)
Discussion started by: richsark
0 Replies

5. Shell Programming and Scripting

wrapper script in perl

Hi, I am in need of way to facilitate this senerio in a perl script. I have CLI ( command line interface) which I run like so: kip-tepltist -u Xxx -p Xxx Which produces tones of names from each template it found: 194Iselin-NJ 33-IDFLB-North-611-Woodward-8600 ... (5 Replies)
Discussion started by: richsark
5 Replies

6. Shell Programming and Scripting

Count script wrapper help

I have this a code that I got help with for another task. I since tried to modify it to work on this task. I need someones expertise to modify it slightly and I am not sure where to start or yet fully understand the logic. I am trying to get a script to read my m-names.txt which has lots... (19 Replies)
Discussion started by: richsark
19 Replies

7. UNIX for Advanced & Expert Users

Pass parameter to the main script from wrapper script

Hi, I am writing a wrapper script(wrap_script.sh) to one of the main scripts (main_script.sh) The main script is executed as following: ./main_script.sh <LIST> <STARTDATE> <ENDDATE> looks for a parameter which is a LIST(consists of different list names that need to be processed), START/END... (0 Replies)
Discussion started by: stunnerz_84
0 Replies

8. Shell Programming and Scripting

Wrapper Script in Perl Or shell

Hello, My requirement is based on Oracle where we run a perl script and it asked some questions.I want to write a wrapper which will answer all these questions. How is it possible. Thanks (16 Replies)
Discussion started by: cotton
16 Replies

9. Shell Programming and Scripting

problem with the my wrapper script

Hi friends, i am working in ksh88. i am running the follwing wapper script in background to run two jobs parallely((eg nohup wrapper.ksh &):: wrapper.ksh ######################## #!/bin/ksh nohup ./pii_insert.ksh /nsing83/p2/test & nohup ./pii_update.ksh... (1 Reply)
Discussion started by: neelmani
1 Replies

10. Programming

Wrapper for unix program - urgent help needed

Hello all , i need some help asap i have a program that keeps killing the machine when i did google searches and 2 days later i ran strace it seems the programm keeps making a system call to gettimeofday to i guess increment a counter ? gettimeofday({1347986584, 464904}, NULL) = 0... (6 Replies)
Discussion started by: NetworkLearning
6 Replies
GIT-SH-I18N(1)							    Git Manual							    GIT-SH-I18N(1)

NAME
git-sh-i18n - Git's i18n setup code for shell scripts SYNOPSIS
. "$(git --exec-path)/git-sh-i18n" DESCRIPTION
This is not a command the end user would want to run. Ever. This documentation is meant for people who are studying the Porcelain-ish scripts and/or are writing new ones. The 'git sh-i18n scriptlet is designed to be sourced (using .) by Git's porcelain programs implemented in shell script. It provides wrappers for the GNU gettext and eval_gettext functions accessible through the gettext.sh script, and provides pass-through fallbacks on systems without GNU gettext. FUNCTIONS
gettext Currently a dummy fall-through function implemented as a wrapper around printf(1). Will be replaced by a real gettext implementation in a later version. eval_gettext Currently a dummy fall-through function implemented as a wrapper around printf(1) with variables expanded by the git-sh- i18n--envsubst(1) helper. Will be replaced by a real gettext implementation in a later version. GIT
Part of the git(1) suite Git 1.8.5.3 01/14/2014 GIT-SH-I18N(1)
All times are GMT -4. The time now is 01:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy