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.
-
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?
-
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?
-
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.
#!/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