Paymentech file comparison in Linux

Posted by Jiltin     30 October, 2008    626 views   

This shows the power of Linux shell script to compare the contents of the file. Paymentech credit card/debit card processor gets the settlement file, and acknowledges the settlement file after processing the file. The return file or acknowledgment file contains the same records with additional remarks (normally “Y”) of acknowledgment. On some days, the acknowledgment fails. In such case, this script finds the files which are not acknowledged at any given time. At the end, it sends an email listing the not acknowledged file details.
Assumption: Both forward and return files are located at the same directory (here /tmp/batch)

Feel free to copy and modify as per your requirement.

#!/bin/sh
#
# Developed by Jiltin
# Paymentech files Not acknowledged
#
FILENAME="Missing_FTP_Files.txt"
if [ -f $FILENAME ]
then
rm -rf $FILENAME
echo "Old Data File ($FILENAME) deleted…"
fi
SRCDIR="/tmp/batch"
FTITLE="Missing ftp files dated `date`"
echo ${FTITLE} ‘ tee -a ${FILENAME}
#
#
SRCLIST=`ls -C1 ${SRCDIR} ‘
grep -v backup ‘ grep -v done`
for ARG in $SRCLIST
do
#echo "${SRCDIR}/${ARG}"
VAR=`grep -i "^S" "${SRCDIR}/${ARG}" ‘
head -1 ‘ cut -b1-20`
#echo $VAR
#VAR=`cut -b1-20 "${SRCDIR}/${ARG}" ‘
head -2 ‘ tail -1 `
#echo "grep -i ${VAR} ${SRCDIR}/*done"
RES=`grep -i ${VAR} ${SRCDIR}/*done`
#echo "${RES}"
if [ -z "${RES}" ]; then
echo "`ls -ltr ${SRCDIR}/${ARG}` `tail -2 ${SRCDIR}/${ARG} ‘
head -1 ‘ cut -b59-72`" ‘ tee -a  ${FILENAME}
fi
done
if [ -f $FILENAME ]
then
FILESIZE=$(stat -c%s "$FILENAME")
if [ $FILESIZE -gt 52 ]
then
uuencode $FILENAME $FILENAME ‘ mail -s "${FTITLE}" "admin@notesbit.com"
fi
fi

Following Google Searches Lead To This Post: libXp-1.0.0-8.i386.rpm oracle linux redhat

Post to Twitter  Post to Delicious  Post to Digg    Post to StumbleUpon

Categories : Scripts Unix Tags : , ,

Comments

No comments yet.


Leave a comment

(required)

(required)