-->
  • Recent Articles

    Script to Check Empty Files, Copy Files & Log them

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


    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