Hi,
I have a unix FTP script to get the file from remote server to DS server. And the script will send an email whether the transfer is successful or failure.
Now i also need to log audit data. For example the file name , file size . record count in the file etc.. what are the options to capture the log audit info?
Could you please give some suggestions ..
Below is the script
#!/usr/bin/ksh
# name: GetFile.ksh
#
# purpose:
#
# Script to get files from FTP share site.
# One control file is used
#
# /ds/etc/FTPPassword.ctl (text file in secured location)
#
# revisions:
#
# 11-18-08, vvivek, Initial Version
# -----------------------------------------------------------------------------
# set environment
# -----------------------------------------------------------------------------
#set -vx
SetEnv()
{
logDir=/export/home/vvivek
PasswordCtl=/export/home/vvivek/FTPPassword.ctl
FTPInDir=/export/home/vvivek
emailGroup=vvivek@amtech.com
}
FTPFile()
{
rcFTP=0
\echo "Receiving $FileName from ftphost ($ServerName)..."
\ftp -inv <<EOF > $ftpLog
open $ServerName
user "$Ftpusername" $Ftppassword
lcd $Ftplocaldir
get $FileName $FileName
quit
EOF
#--------------------------------------------------------------
# checking for the errors during FTP process
#--------------------------------------------------------------
if [[ -s $ftpLog ]]; then
if [[ -n $(\grep "^226 Transfer complete." $ftpLog) ]]; then
rcFTP=0
else
rcFTP=1
fi
else
\echo "****** unknown error with FTP while getting file ($FileName)! ********"
rcFTP=1
fi
}
# -----------------------------------------------------------------------------
# main
# -----------------------------------------------------------------------------
Me=$(\echo $0 | \awk -F"/" '{print $NF}')
mypath=$(\echo $0 | \awk -F"$Me" '{print $1}')
SetEnv
pid=$$
logFile=$logDir/$(\echo $Me | \awk -F. '{print $1}').log.$(\date +%Y%m%d)
exec 1>$logFile
exec 2>&1
ftpLog=$logDir/$(\echo $Me | \awk -F. '{print $1}')_FTPLog_$pid.log
tmpFile=$logDir/$(\echo $Me | \awk -F. '{print $1}').tmp
if [ ! -f $PasswordCtl ]
then
echo "******** Password file $PasswordCtl not found. Aborting the job ************"
subject="$Me FAILED - Password file not found"
uuencode $logFile $logFile > $tmpFile
print 'Pls check the attached log file \n\nThanks' >>$tmpFile
mailx -s "$subject" $emailGroup < $tmpFile
exit 1
fi
#-------------------------------------------------------
# Reading parameters from Password.ctl file
#-------------------------------------------------------
ServerName=`grep '^FTPIn1' $PasswordCtl | cut -f2 -d'|'`
Ftpusername=`grep '^FTPIn1' $PasswordCtl | cut -f3 -d'|'`
Ftppassword=`grep '^FTPIn1' $PasswordCtl | cut -f4 -d'|'`
FileName=`grep '^FTPIn1' $PasswordCtl | cut -f5 -d'|'`
Ftplocaldir="$FTPInDir"
#-------------------------------------------------------------
# Transferring the data file
#-------------------------------------------------------------
FTPFile
if [[ $rcFTP != 0 ]]; then
echo "********* unable to get the file ($FileName) from ftphost ($ServerName)! *********"
subject="$Me FAILED - FTP of file failed"
uuencode $logFile $logFile > $tmpFile
uuencode $ftpLog $ftpLog >> $tmpFile
print 'Pls check the attached FTP log for errors \n\nThanks' >>$tmpFile
mailx -s "$subject" $emailGroup < $tmpFile
exit 1
fi
echo "File $FileName successfully transferred from $ServerName at $(\date '+%m-%d-%y %H:%M:%S')"
subject="$Me Success - FTP of file successful"
uuencode $logFile $logFile > $tmpFile
uuencode $ftpLog $ftpLog >> $tmpFile
print 'File has been Transferred successfully.Pls check the attached logs \n\nThanks' >>$tmpFile
mailx -s "$subject" $emailGroup < $tmpFile
rm -f $ftpLog
rm -f $tmpFile
exit 0
Thanks in Advance..
How to capture log audit data
Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.
Moderators: chulett, rschirm, roy
Return to “IBM<sup>®</sup> DataStage Enterprise Edition (Formerly Parallel Extender/PX)”
Jump to
- Moderators' Choice
- ↳ Editor's BLOG Corner
- ↳ Ask the Experts! - Dads and Grads
- ↳ DSXchange Testimonials
- ↳ Cognos (IBM BI)
- FAQs
- ↳ FAQs
- ↳ FAQ Discussion
- DataStage
- ↳ General
- ↳ IBM<sup>®</sup> Infosphere DataStage Server Edition
- ↳ IBM<sup>®</sup> DataStage Enterprise Edition (Formerly Parallel Extender/PX)
- ↳ Archive of DataStage Users@Oliver.com
- IBM<sup>®</sup>Infosphere Products<sup></sup>
- ↳ Business Glossary
- Suggestions
- ↳ Site/Forum
- ↳ Enhancement Wish List
- Consulting
- ↳ Talent
- ↳ Looking for Talent
- Support
- ↳ Parameter Manager
- ↳ Compile All Plus
- Usergroup Forums
- ↳ Usergroup Central Forum
- ↳ Heartland Usergroup Forum
- The Written Word
- ↳ Articles, White Papers and Tips and Tricks
- ↳ Product Documentation
- Third Party Applications
- ↳ Third Party Applications
- Product Derivatives
- ↳ Functions
- ↳ Routines
- ↳ Jobs
- ↳ Logs
- Tools
- ↳ Tools Forum
- Category
- ↳ Infosphere Master Data Management
- ↳ Data Quality Best Practices
- ↳ IBM QualityStage
- ↳ Information Analyzer (formerly ProfileStage)
- ↳ IBM<sup>®</sup> SOA Editions (Formerly RTI Services)
- ↳ IBM<sup>®</sup> DataStage TX
- ↳ BI
- ↳ Data Integration