• Recent Articles

    Script to Check Empty Files, Copy Files & Log them

    ls -ld /home/oracle/hk/ofc_data/*.CSV | awk {'print $9'} > /tmp/filename.txt
    for i in `cat /tmp/filename.txt`
    [ ! -f "$i" ] && { echo "Error: $0 file not found."; exit 2; }
    if [ -s "$i" ]
    scp -vpr $i nano@ |& grep -e Deena >> /tmp/scp_log.txt 2>&1
    mv -f $i /home/oracle/hk/ofc_data/Archive/
            echo "$i is empty." |/bin/mailx -a /tmp/scp_log.txt -s "Denna DATA FTP ISSUE Please check" manas.tri@gmail.com

    We have following checks now.
    a. Now it’ll check if the File exists or not?
    b. If the File exists , is it an empty File or Not?
    c. If it is not an empty file it’ll copy the file to FTP Location and move the original File to Archive Location.
    d. If it is an empty File, then it’ll send an e-mail to admin with log file attached.

    No comments