Hi Corona,
thanks for all your inputs, my script tars a file and I am able to extract individual files. the environment file was set up today and I need to use it, for which I changed my script and then I came to know about 2 issues in the script:
1. The script looks for files in the sub directories of the folder where as subdirectory level search is not required.
2. I am looking only for files with certain pattern. below are the file names. but the script does like a wildcard match (if a file name has the $date value in some sub directory, it picks it and tars it), it does not match the complete file name..even if a part of the file name is available, (like .TXT or $ENVID) it picks it and tars it...
PHP Code:
$ENVID_DATA_*_$DATE.$ENVID_DAT.TXT
$ENVID_CONTROL_*_$DATE.$ENVID_CTRL.TXT
$ENVID_TRIGGER_$ENVID.$ENVID.TRG.TXT - ( the script I posted here is yet to accomodate this file)
code:
HTML Code:
$ cat archival.sh
#### Script to archieve source file and tar them
#!/bin/sh
. /opt/informatica/infa_shared/SCRIPTS/env_file.ksh
date_str=`date "+%Y%m%d%H%M%S"`
ENVID=$1
logfile=$LOGS/${ENVID}_archival_${date_str}.log
echo Script $0 started at `date` >${logfile}
#### Check if one parameter is received#######
if [ $# -ne 1 ]; then
echo "input parameter for the script is missing" >>${logfile} 2>&1
exit 1
fi
##### Get the ENVID and DATE_OF_RUN from the parameter file####
parmfilename=$PARM_FILES/${ENVID}_parm.parm
echo $parmfilename >>${logfile}
DATE_OF_RUN=`cat $parmfilename | grep "DATE_OF_RUN" | cut -d"=" -f2`
echo $DATE_OF_RUN >>${logfile}
#### List files based on input parameter####
TARFILE=$ARCHIVE/${ENVID}_${DATE_OF_RUN}_$(date +"%Y%m%d%H%M%S").tar.gz
# Create the compressed tar file
#tar -zcf "${TARFILE}" ${ENVID}_*_${DATE_OF_RUN}.${ENVID}_*.TXT $SOURCE_FOLDER
tar -zcf "${TARFILE}" ${ENVID}_DATA_${DATE_OF_RUN}.${ENVID}_DAT.TXT ${ENVID}_CONTROL_${DATE_OF_RUN}.${ENVID}_CTRL.TXT $SOURCE_FOLDER
# List files inside the tar file
tar -ztf "${TARFILE}" >>${logfile}
can you please help me..