Wednesday, September 19, 2012

Add a right-click menu item for ClamAV on Debian Linux

ClamAV has provided some commands for scanning computer viruses. More information can be found here.

I would like to see an option in the right-click menu for scanning viruses. I installed Nautilus Actions Configuration Tool (NAC Tool). nautilus-actions was the name of the package I installed.









I also installed xterm for displaying the results after scanning viruses. The full name of xterm was "X terminal emulator".

I knew that I had installed ClamAV.

Before using the NAC Tool, I wrote bash scripts.

I copied and saved the following in a file called "scan1.sh".

#!/bin/bash
# This script will test if you have given a leap year or not.
#---- usage:  ./scan1.sh '/path/to/files'

pathToLogFile='/path/To/File/ScanLog.txt'
startTime=`date -u`


echo "Start Time: $startTime"

echo "" >> $pathToLogFile
echo "====" >> $pathToLogFile
echo "Start Time: $startTime" >> $pathToLogFile
echo "Scan $@"
echo "Scan $@" >> $pathToLogFile

/usr/local/bin/clamscan -ri --log="$pathToLogFile" "$@"

endTime=`date -u`

echo "End Time: $endTime" >> $pathToLogFile
echo "====" >> $pathToLogFile
echo ""
echo "End Time: $endTime"
echo "Log File Saved: $pathToLogFile"
echo "Press Enter to exit..."

read enterToExit


Then, in Terminal, I typed: (This made the file executable.)
chmod 755 /path/To/File/scan1.sh

I copied and saved the following in a file called "scanTerm.sh".

#!/bin/bash
# Show the scan results

xterm -e "/path/To/File/scan1.sh $@; bash"

Then, in Terminal, I typed: (This made the file executable.)
chmod 755 /path/To/File/scanTerm.sh




Using NAC Tool

I selected the options below:

System -> Preferences -> Nautilus Actions Configuration

I made the changes below:

Under the Action tab, I checked all boxes, except "Read-only":

Display item in selection context menu
Display item in location context menu
Context label: Scan Virus

Display item in the toolbar

Action properties
Enabled

Under the Command tab, I chose and typed:

Label: ClamScan

Command: /path/To/ScanTerm.sh

Parameters: %M


Under the Folders tab, I chose and typed:

/

Under the Conditions tab, I chose and typed:

Appears if selection contains
Both (files and folders)
Appears if selection has multiple files or folders

Under the Advanced conditions tab, I chose and typed:

Appears if scheme is in this list
file (Local files)
(I checked all boxes, including this one.)


I put some files in a folder. I scanned the folder by selecting Scan Virus. It worked. This was a nice feature.

However, when I selected some folders and selected Scan Virus, it did not work.



Reference

I visited a page related to Ubuntu for more information.

No comments: