Script for clamav help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for clamav help
# 1  
Old 06-06-2010
Script for clamav help

Hi there all, I am writing a script to run clamscan and email me the results, everything is working fine still it comes to mailing me the results. Any and all help is much welcomed.

Code:
#!/bin/sh
#
# Script Written by Jonathan Wood

# Varables to change 
mailrecp="mail@home.jwservices.co.nz" 
scanpath="/home/ftp"

# Setting other varables
oldpath="/var/log/clamav/"
oldlog="clamav_scan.log.old"
filepath="/tmp/"
log="clamav_scan.log"
infected="/root/infected"
mailsub="Daily Virus Scan for $(hostname)"
    if [ -e $filepath$log ]; then
                echo "Starting Scan"
                echo "Scanning "$scanpath
                echo "Moving old Scan Log"
                mv $filepath$log $oldpath$oldlog
                touch $filepath$log
                echo "Using "$filepath$log " as log file"
                if [ -d $intected]; then
                    echo $infected" Already created, moving on..."
                    echo .
                else
                    echo $infected" Does not exist"
                    echo "Creating "$infected
                    echo .
                    mkdir $infected
                fi
                echo "moving all infected files to : "$infected
                clamscan -l$filepath$log -i --move=$infected -r $scanpath --detect-pua=yes
        else
                echo $filepath$log" does not exist"
                echo .
                echo "Createing log file in "$filepath
                touch $filepath$log
                echo "Using "$filepath$log " as log file"
                echo "moving all infected files to : "$infected
                if [ -d $intected]; then
                    echo $infected" Already created, moving on..."
                else
                    echo $infected" Does not exist"
                    echo .
                    echo "Creating "$infected
                    mkdir $infected
                fi
                echo "Now Running Scan. Please Wait"
                echo "Scanning "$scanpath
                clamscan -l$filepath$log -i --move=$infected -r $scanpath --detect-pua=yes

    fi

echo "Sending "$filepath$log "to "$mailrecp
(cat $filepath$log) | mailx -s \"$mailsub\" $mailrecp

# 2  
Old 06-06-2010
So what's your problem? don't get mail or others?
# 3  
Old 06-06-2010
Sorry, The script is working till it comes to sending the message, it is trying to send the message to the subject string
# 4  
Old 06-07-2010
Change the last line to:
Code:
cat $filepath$log | mailx -s "$mailsub" $mailrecp

This User Gave Thanks to rdcwayx For This Post:
# 5  
Old 06-07-2010
Cheers, thanks for that help, how works like a charm

Last edited by jonnowood; 06-07-2010 at 06:57 AM.. Reason: Spelling
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

ClamAV/other AV. Possible to make portable?

Hey guys/gals, I work with a large amount of servers, and was just curious if it is possible to make a linux AV app, portable. What i mean is, I go to a user's home directory and do something like ./clamavscan (I suppose an alias for clamscan..), and it scans the user's home directory for... (2 Replies)
Discussion started by: Rhije
2 Replies
Login or Register to Ask a Question