Sponsored Content
Full Discussion: Script for clamav help
Top Forums Shell Programming and Scripting Script for clamav help Post 302427496 by jonnowood on Sunday 6th of June 2010 05:59:55 PM
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

 

We Also Found This Discussion For You

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
line(1) 						      General Commands Manual							   line(1)

NAME
line - Reads one line from standard input SYNOPSIS
line STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: line: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
None DESCRIPTION
The line command copies one line, up to and including a newline, from standard input and writes it to standard output. Use this command within a shell command file to read from your terminal. The line command always writes at least a newline character. NOTES
The line utility has no internationalization features and is marked LEGACY in XCU Issue 5. Use the read utility instead. EXIT STATUS
Success. End-of-File. EXAMPLES
To read a line from the keyboard and append it to a file, enter: echo 'Enter comments for the log:' echo ': c' line >>log This shell procedure displays the message: Enter comments for the log: It then reads a line of text from the keyboard and adds it to the end of the file log. The echo ': c' command displays a : (colon) prompt. See the echo command for information about the c escape sequence. SEE ALSO
Commands: echo(1), ksh(1), read(1), Bourne shell sh(1b), POSIX shell sh(1p) Functions: read(2) Standards: standards(5) line(1)
All times are GMT -4. The time now is 08:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy