** I have written a scripts to find files continuous in all folder and send files to sftp and similarly wise a versa.But Now is want to do checksum of file and ensure that file is transfer to sftp properly.I tried the cksum as my OS is AIX but unable to do verification of both files checksum. **
```#!/bin/ksh
/* FileList="/data1/RBIADF_SFTP/Outbound/logs/Filelist.lst" */
/* IniFile="/data1/RBIADF_SFTP/CommonFiles/inbound.ini" */
/* ProcessLog="/data1/RBIADF_SFTP/Outbound/logs/ProcessLogs.Log" */
echo $(date '+%d/%m/%Y %H:%M:%S') ": Directory File Watcher Started..." >> $ProcessLog
while [ 0 ]
do
Loop=0
while IFS="," read -r f1 f2 f3 f4 f5 f6
do
if [ $Loop != 0 ]
then
if [ "${f5}" != "NA" ];
then
IsFileFound=$(find "${f5}" \( ! -name $f6 -o -type f \) -prune -type f | wc -l)
if [ $IsFileFound -ge 1 ];
then
echo $(date '+%d/%m/%Y %H:%M:%S') ": ##STRART TRANSACTION##" >> $ProcessLog
echo $(date '+%d/%m/%Y %H:%M:%S') ": File Found Processing Started... " >> $ProcessLog
echo $(date '+%d/%m/%Y %H:%M:%S') ": Processing File type= $f1, local path=$f5, SFTP Path =$f4" >> $ProcessLog
ls -p $f5 | grep -v / >> $ProcessLog
ls -p $f5 | grep -v / > $FileList
dirpath=$f5
DIR_NAME=$(date '+%d%m%Y')
sh PUTFILES.sh $f4 $f5
sleep 5
echo $(date '+%d/%m/%Y %H:%M:%S') ": File Get Completed." >> $ProcessLog
Archive_FOLDER_COUNT=$(find "${f5}/archive/" \( ! -name 'archive' -o -type d \) -prune -type d | wc -l)
echo $(date '+%d/%m/%Y %H:%M:%S') ": Local File Archive Started. Archive Path=$f5/archive/$DIR_NAME" >> $ProcessLog
if [ $Archive_FOLDER_COUNT != '1' ]
then
mkdir $f5/archive/
fi
FOLDER_COUNT=$(find "${f5}/archive/$DIR_NAME" \( ! -name $DIR_NAME -o -type d \) -prune -type d | wc -l)
if [ $FOLDER_COUNT != '1' ]
then
mkdir $f5/archive/$DIR_NAME
fi
while IFS="," read -r sf1
do
echo $dirpath/$sf1 $dirpath/archive/$DIR_NAME/
mv $dirpath/"${sf1}" $dirpath/archive/$DIR_NAME/
done <"$FileList"
echo $(date '+%d/%m/%Y %H:%M:%S') ": Processing File type= $f1 Completed.." >> $ProcessLog
echo $(date '+%d/%m/%Y %H:%M:%S') ": ##END TRANSACTION##" >> $ProcessLog
fi
fi
fi
let "Loop=Loop+1"
done <"$IniFile"
done
```
```
##### PUTFILES.sh ####
cd $2
#!/bin/ksh
HOST=dpcftpuat.hbctxdom.com
PORT=22
USER=rbisftp
PASS_DIR="/home/oracle/autoscp/enc_pass_dir"
export PASS_DIR
PASSWORD=`cat $PASS_DIR/pass_dpcftpuat.hbctxdom.com.enc|openssl enc -aes-128-cbc -a -d -salt -pass pass:hdfc`
export HOST PORT USER PASSWORD SOURCE_FILE TARGET_DIR
##- Call expect
/usr/bin/expect<< EOF
set timeout -1
spawn /usr/bin/sftp $USER@$HOST
expect "password:"
send "$PASSWORD\r"
expect "sftp>"
send "cd $1/ \r"
expect "sftp>"
send "mput *.* \r"
expect "sftp>"
send "bye\r"
EOF
echo "SFTP DONE"
exit
```
**I expect that the checksum is capture of file before transferring to sftp and checksum is done after transferring to sftp and same is return in log.****