LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-08-2009, 11:11 AM   #1
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Rep: Reputation: 39
clamav script not listing output


Hi there --

I wrote a script that does an update to the virus database, and then runs a recursive check of all directories, with certain exceptions, on the
system in question. Listed below is the script in two versions. The first version excludes several directories,

Code:
#!/bin/bash

# The purpose of this scipr is to initiate a scan of the
# linux partitions, and if necessary, remove any files that
# are suspected of being infected by viruses or trojans.

# First run the freshclam utility to update the virus definition
# files to the latest version available. NOTE: The system must
# have a network, and by extension, Internet access in order for
# this to work.

/usr/local/bin/freshclam > /tmp/freshclam_update.txt
ls -l /var/lib/clamav >> /tmp/freshclam_update.txt
mail -s "<Server Name> Freshclam Update Results" <system administrator> < /tmp/freshclam_update.txt

# Initiate the antivirus scan on the linux partitions. The options
# included in the command syntax will have the scan go recursively
# through all directories, and if a suspect file is found, it will
# be moved to quarantine.
# NOTE: The /proc, /sys, and /dev directories are excluded from the
# scan due to their contents not being actual files but 'portals' to
# internal data structures of the operating system. Scanning these 
# directories can cause adverse side-effects.
cd /
/usr/local/bin/clamscan -r --exclude-dir=/proc --exclude-dir=/sys --exclude-dir=/dev --move=/tmp/quarantine > /tmp/clamscan_output.txt

# Go to the output file that was generated, and remove all lines that have
# the status of OK.
cd /tmp
grep -v ' OK' clamscan_output.txt | grep -v 'Empty file' | grep -v 'Excluded' > /tmp/clamscan_outputsummary.txt

# E-mail the results of the scan to the system administrator.
mail -s "<Server Name> Clamscan Results" <system administrator> < /tmp/clamscan_outputsummary.txt

while the other does not use the exclusion option.

Code:
#!/bin/bash

# The purpose of this scipr is to initiate a scan of the
# linux partitions, and if necessary, remove any files that
# are suspected of being infected by viruses or trojans.

# First run the freshclam utility to update the virus definition
# files to the latest version available. NOTE: The system must
# have a network, and by extension, Internet access in order for
# this to work.

/usr/local/bin/freshclam > /tmp/freshclam_update.txt
ls -l /var/lib/clamav >> /tmp/freshclam_update.txt
mailx -s "<Server Name> Freshclam Update Results" <system administrator> < /tmp/freshclam_update.txt

# Initiate the antivirus scan on the linux partitions. The options
# included in the command syntax will have the scan go recursively
# through all directories, and if a suspect file is found, it will
# be moved to quarantine.
cd /
/usr/local/bin/clamscan -r --move=/tmp/quarantine > /tmp/clamscan_output.txt

# Go to the output file that was generated, and remove all lines that have
# the status of OK and other extraneous entries.
cd /tmp
grep -v ' OK' clamscan_output.txt | grep -v 'Empty file' | grep -v 'Excluded' > /tmp/clamscan_outputsummary.txt

# E-mail the results of the scan to the system administrator.
mailx -s "<Server Name> Clamscan Results" <system administrator> < /tmp/clamscan_outputsummary.txt
The two versions of the script run respectively on a SuSE and Fedora server.

I upgraded clamav from version 0.94.2 to the 0.95 distribution last night. After completing the installation, I ran the ldconfig command to ensure all libraries were up to date. The script shown above was scheduled to run at 1:00 AM this morning. A check of my e-mail indicated that while the freshclam update was successful, the output files were totally blank.

Does anyone have any idea as to why this happened, and what I can do to correct it? Thanks.
 
Old 04-09-2009, 08:34 PM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Are you sure that's the correct location for clamscan and not /usr/bin?
 
Old 04-10-2009, 12:08 PM   #3
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Hi there --

Thanks for your reply. I found the answer to the problem: The /tmp/quarantine directory did not exist. The absence of the destination caused the problem.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Output rpm cmd listing onto a CD? flasun Linux - Newbie 2 02-12-2009 06:57 AM
Listing files including full path in the output googlix Linux - General 9 11-24-2007 05:18 AM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
Screen Listing Output Save in a File rolly frando Linux - Newbie 3 07-04-2005 01:23 AM
Colours in directory listing and XMMS Output plugins Kristijan Linux - Newbie 3 02-22-2004 07:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration