Important information
-- Information on MX15/16 GPG Keys
-- Spectre and Meltdown vulnerabilities

-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-18 Final release info here
-- Migration Information to MX-18 here
-- antiX-17.3 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

ClamAV script

Here you can exchange scripts that you created or have permission to share with other users.
Post Reply
User avatar
Forum Regular
Forum Regular
Posts: 358
Joined: Fri Nov 02, 2007 4:39 pm

ClamAV script


Post by GDixon » Fri Oct 31, 2014 2:43 pm

Heres something to use clamav from a desktop icon.
I'm working on constants and functions with if else scripting and log files or functions, if anyone has any suggestions on cleaning this script up or improving it let me know. I accept all comments both good and not so good.

This is for the desktop icon

Code: Select all

[Desktop Entry]
Comment[en_US]=use clamav to scan TvShows hard drive
Comment=use clamav to scan TvShows hard drive
Name[en_US]=Scan TvShows
Name=Scan TvShows

Heres the avscan script

Code: Select all


# Remember to make executable and check permisions

# To scan drives for a virus using ClamAV

# You will need clamav and it's depends installed.

# If you want to make use of any success and or error sounds using ogg or mp3
# I suggest installing mplayer and using it in a script.
# line below will run mplayer in the background avoiding
# mplayers quite verbose output, play the ogg file and close.
#     Example : use below in a script making needed changes for your system.
# mplayer /usr/share/sounds/clam_ogg/Clam-Success.ogg </dev/null >/dev/null 2>&1 &

# constants

RIGHT_NOW=$(date "+ %a %x %r")
NO_DRIVE="Failed to scan: Not plugged in and or mounted"
YIKES="Yikes drive not plugged in and or mounted : Nothing to scan"

# variables

TARGET="/media/TvShows"                # usb 1T HDD
VIRUS="/home/Greg/.VIRUS/"             # directory you want the virus's moved to
HIDE="(hidden directory)"              # uncomment if VIRUS is a hidden directory
SCAN_LOG="/home/Greg/ScanLog/Clam.log" # directory you want the scan log placed


if [ -d $TARGET ]; then

    echo -e  "Getting ready to scan $TARGET for any viruses\n"
    echo -e  "If any infected files are found they will be\n"
    echo -e  "moved to $VIRUS $HIDE\n"
    echo -e  "Scan Log will be in $SCAN_LOG\n"
    echo -e  "Scan will begin shortly, be patient $USER\n"

clamscan -r --move=$VIRUS $TARGET -l $SCAN_LOG  # clamscan command and arguments/options

# to play a sound script on success uncomment and edit as needed


# the commands below put stamps at the end of
# the clam.log file each time virusscan script
# runs as "Updated on day, date, time, user"
# the log appending after else gives a fail if no drive

    echo $TIME_STAMP >> $SCAN_LOG    # used when drive/directory is present

sleep 12; clear

# below is used for log when drive is missing or not mounted 

    echo -e "$YIKES\n"
    echo >> $SCAN_LOG    # makes a blank line in log (for layout and formatting)
    echo -e "-------------------------------------------------------------------------------\n" >> $SCAN_LOG
    echo -e "----------- SCAN FAILED -----------" >> $SCAN_LOG
    echo $NO_DRIVE >> $SCAN_LOG
    echo $TIME_STAMP >> $SCAN_LOG    
    echo >> $SCAN_LOG    # makes a blank line in log (for layout and formatting)

# to play a sound script on error uncomment and edit as needed


sleep 4; clear


I'm also working on figuring out a way to get a progress bar instead of all the files output when scanning. clam av gives the options of nothing, infected files found or all. this is a work in progree. any suggestions ?

I have a cool clam icon but it's bigger than 300k , If anyone wants it send an e-mail and I'll send it that way.

Post Reply

Return to “Scripts”