Vous êtes sur la page 1sur 3

Files_TO_SSI.

sh
#!/bin/bash SCR_DIR="/home/oraprod" BASE_DIR="/u01/PROD/apps/tech_st/10.1.2/appsutil/outbound" DATA_DIR="$BASE_DIR/files" ARCH_DIR="$BASE_DIR/Batch_archive" OUT_DIR="$BASE_DIR/so_files" LOG_DIR="$BASE_DIR/log" LOG_FILE="$LOG_DIR/Files_TO_SSI.log" today=`date +%Y%m%d%H%M%S` . $SCR_DIR/SSI_Login.ksh cd $DATA_DIR > File_List chmod 666 File_List DAT_COUNT=`ls -1 *.DAT | wc -l` ###Removing files which already exist in Archive Dir if [ $DAT_COUNT -ne 0 ] then for file in `ls -1 *.DAT` ; do fn=`echo $file | cut -d"." -f1` if [ ! -f $fn.FLG ] then continue fi ls -1 $fn.DAT $fn.FLG >> File_List done else echo "DAT files are not available to process on `date`" >> $LOG_FILE exit 0 fi ###Checking files existence to Transfer if [ ! -s File_List ] then echo "There are No Files to Transfer on `date`" >> $LOG_FILE exit 0 fi

for file in `cat File_List` ; do ###Moving files to out dir path mv $file $OUT_DIR/ P=$? if [ $P != 0 ] then echo "Failed in moving file to Out Dir on `date`" >> $LOG_FILE exit 1 fi ### FTP files to SSI Server from Out dir chmod 777 $OUT_DIR/$file cd $OUT_DIR echo "user $userid $passwd" > $SCR_DIR/Ftp_SSI.cmd echo "cd /hcom/to_ssi/data" >> $SCR_DIR/Ftp_SSI.cmd echo "ascii" >> $SCR_DIR/Ftp_SSI.cmd echo "put $file" >> $SCR_DIR/Ftp_SSI.cmd echo "chmod 777 $file" >> $SCR_DIR/Ftp_SSI.cmd #echo "cd /hcom/to_ssi/data/archive" >> $SCR_DIR/Ftp_SSI.cmd #echo "put $file $file.$today" >> $SCR_DIR/Ftp_SSI.cmd #echo "chmod 777 $file.$today" >> $SCR_DIR/Ftp_SSI.cmd echo "bye" >> $SCR_DIR/Ftp_SSI.cmd ftp -niv 172.20.54.43 < $SCR_DIR/Ftp_SSI.cmd > $LOG_DIR/Ftp_SSI.log FTP_FILE_COUNT=`grep -ic "File receive OK" $LOG_DIR/Ftp_SSI.log` if [ $FTP_FILE_COUNT != 1 ] then echo "Failed in FTP files to SSI server on `date`" >> $LOG_FILE echo "File Count : $FILE_COUNT FTP File Count : $FTP_FILE_COUNT" >> $LOG_FILE exit 1 fi EXT=`echo $file | cut -d"." -f2` if [ $EXT = "DAT" ] then mv $file $ARCH_DIR/$file.$today P=$?

if [ $P != 0 ] then echo "Failed in moving $file to Archive Dir on `date`" >> $LOG_FILE exit 1 fi fi cd $DATA_DIR done echo "Files Transfered to Remote server successfully on `date`" >> $LOG_FILE echo "Files moved to Archive dir successfully on `date`" >> $LOG_FILE echo "----------------------------------------------------------" >> $LOG_FILE exit 0

Steps 1) If there are no RET*.DAT files are available to transfer, Script will write into the log file, that there are no DAT files available and exit from the script 2) If DAT files are available, but there are no corresponding FLG files then the script will write into the log file mentioning that there are no files to transfer and exit from the script. 3) If both DAT file and corresponding FLG are available, then we are transferring DAT file to SCHEAFER server. If the file transfer is failed, then we are writing into the log file mentioning that script failed while transferring the file and exiting the script. 4) If DAT file transferred to SCHEAFER server successfully, then we are moving the DAT file to the ARCHIVE directory on oracle server. If moving the DAT file to ARCHIVE folder failed, we are writing into the log file mentioning that script failed in moving the file to ARCHIVE folder and exiting the script. 5) If DAT files are all transferred to SCHEAFER successfully and moved to ARCHIVE folder successfully, then we writing into the log file mentioning that the files are transferred successfully and moved to the archive dir. Once completed exiting the script successfully.

Vous aimerez peut-être aussi