Scan with ClamAV (extended)
Dolphin Service Menus
Score 70%
Description:

A short script to scan files or directories with ClamAV.
It provides the ability to scan multiple files, a progress-dialog and a result window.

Installation:
1. Start Dollphin
2. Press "Configure and control Dolphin" > "Configure Dolphin..."
3. Go to "Services"
4. "Download New Services..."
5. Search for my scripts name
6. Press "Install"

You need to have ClamAV installed.
If you encounter any issues when using the graphical way extract the file and run "sh install.sh".

All files are installed in the users home directory (/home/[user]/.kde[4]/share/kde4/services/ServiceMenus/ClamScan/), there is no need to use su or sudo to install

Note:
The script is currently translated in English, Finnish, French, German, Indonesian, Italian, Russian, Spanish, Swedish, Turkish and Ukrainian.
If you wish another language, translate the following and leave me a message or write it in a comment:
Name[en]=Scan with ClamAV
wait="ClamAV is scanning, please wait."
not_found="ClamAV is not installed!"
scan_sentence="Scanning files: "

Translations:
[li]English [/li][li]Finnish (Thanks to nikore90)[/li][li]French (Thanks to pbuard)[/li][li]German[/li][li]Indonesian (Thanks to JamurBulet)[/li][li]Italian (Thanks to Andrea Sciucca)[/li][li]Russian (Thanks to Omega9)[/li][li]Spanish[/li][li]Swedish (Thanks to Jonas Norlander)[/li][li]Turkish (Thanks to tanzer)[/li][li]Ukrainian (Thanks to Localizator (localizator@ukr.net))[/li]
Last changelog:

4 years ago

2013-6-18 (2.5.7)
- fixed permissions

2012-9-16 (2.5.6)
- fix: install-script: create path2 if it doesn't exist

2012-4-21 (2.5.5)
- support for linked directories
- support for empty directories
- unnecessary logfile gets deleted after scan, only result file remains
- fixed some if-conditions
- counts directories

2012-4-19 (2.5.4)
- fixed a wrong directory test (minor bug); now [ -d ] instead of [ -f ]
- did some testing on the mountable devices .desktop file, seems to work fine now

2012-4-19 (2.5.3)
- fixed a wrong set directory (~/.kde4/...) (that was for testing, I forgot to remove it)
- added spanish
- fixed this bug: gentooforum.de/artikel/17867/2/update-script.html when running ClamScan.sh without syntax

2012-2-23 (2.5.2)
- fixed recognition of empty directories which I broke in 2.3

2012-2-23 (2.5.1)
- Indonesian translation

2012-2-4 (2.5)
- using mkdir -p instead of if-conditions

(See Changelog file)

Don't forget to vote!

b606

1 month ago

I ported your service menu to the KDE Framework 5, with some additional modifications (more accurate progressbar, etc). Do you have the files in github so that I can fork/push my modifs there ?

Report

lm789632

1 month ago

Maybe you can create a new Service Menus .

Report

mcmurchy1917

3 years ago

AS it stands the script ClamScan.sh uses clamscan as the scanner.

As I have clamd running I've amended the script ClamScan.sh to use clamdscan instead. Needed a bit of rework to cater for the differences in the information they write to the log files and of course clamd must be running.

The time to scan has reduced quite significantly. I tested on a directory with 1210 files and 9 sub-directories with a size of 3.2G, in the directory there were 19 infected files. My machine is 10 years old with P4 and 2G of memory.

Using clamscan it took on average 14 mins.

Clamdscan took on average 2.5 minutes.

Not quite sure what to do with it. Let me know whoever might be interested. It doesn't cater for symbolic links. So really this is just a heads up.

Alex

Report

Incarus

3 years ago

The thought behind using clamscan instead of clamdscan is that not everybody is running or using clamdscan. Not sure if at the mean time something changed about that, but it was at least not easy back in that time to set up clamdscan, at least clamscan was running out of the box.

A possible fix for this would be to let the script check if clamdscan is running and if yes to prefer that one.

Report

Incarus

3 years ago

the current command to run clamscan in this script is:

nohup clamscan -r --log="$spath"/ServiceMenus/ClamScan/logs/ClamScan_result_$date.log --stdout $real_files > "$spath"/ServiceMenus/ClamScan/logs/ClamScan_$date.log 2>&1 &

we could swap it to something like

if [ "$(pidof clamdscan)" ]
then
nohup clamdscan [...]
else
nohup clamscan [...]
fi

not sure if that is working.

Report

mcmurchy1917

3 years ago

Firstly can I say this is a great tool and note that Incarus has "retired" as maintainer.

However, I've noticed that the progress bar in kdialog doesn't behave correctly.

I believe this patch resolves the issue -

--- ClamScan.sh.clamscan 2013-12-04 16:28:42.137603031 +0000
+++ ClamScan.sh 2013-12-05 10:40:06.303412347 +0000
@@ -8,7 +8,7 @@
files_old=$*
IFS="," #new separator instead of spaces
files=${files_old//\ \//,\/} #from " /" to ",/"
-version="2.5.5"
+version="2.5.8"
title="ClamScan $version"
date="$(date +"%H-%M-%S_%d-%m-%Y")"
path="$(kde4-config --path services)"
@@ -85,7 +85,7 @@
current_lines="0"

progress=$(kdialog --title "$title" --progressbar "$wait
-$scan_sentence $complete_amount ($complete_amount_dir directories)")
+$scan_sentence $complete_amount ($complete_amount_dir directories)" $complete_amount)

#qdbus $progress org.kde.kdialog.ProgressDialog.showCancelButton true
else

Report

Xwang1976

3 years ago

I've manually applied the patch and still the progress bar does not update at all.
Can you help me, please?

Report

Incarus

3 years ago

So let's see what the problem is here. The script actually checks the amount of lines in the file

"$spath"/ServiceMenus/ClamScan/logs/ClamScan_$date.log

each scanned file creates exactly one new line in that file, so if the amount of lines in the file == amount of all selected files the progressbar should be 100% (or x of x files).
Does the mentioned file exist on your computer (is it creating while scanning)?

Report

Xwang1976

3 years ago

Yes, it is created and the files are added to it (it is automatically removed when I close the popup which contains the scan results).

Report

mcmurchy1917

3 years ago

I found there was a significant overhead in using clamscan for scanning small numbers of files.

On my system it takes about 7.318 secs to load the dictionary and scan the smallest file in a directory. Whereas if I scan all 11 files in the directory clamscan takes 7.785 secs so really it takes only 0.467 secs to scan the 11 files.

How this may be represented in the progress bar is that it displays the bar waits 7.318 secs at 0% then progresses to 100% in the remaining 0.467 secs them closes. Is this what you see?

I think this was one of the reasons I swapped over to using clamdscan.


In this scenario the progress bar might not register anything for the first 7 secs and then

Report

Incarus

3 years ago

This is actually a wanted behaviour. The progressbar is set to for example 1300, if you scan 1300 files. A small file will also count as much as a big file for the progressbar. It would be possibly to change that behavior but it would increase the amount of code. For example you could check how big the single files are (in order of the scanned files) and give the single lines a relative count (the script checks the lines of the log file: 1 more line in the log file is +1 for the progressbar until amount of lines = amount of selected files = length of the progressbar.

Report

Xwang1976

3 years ago

My problem is that I don't see the progress bar at all even if I scan more files.
Xwang

Report

Incarus

3 years ago

The problem is that I can't fix this right now as I don't have access to a linux machine.

Report

mcmurchy1917

3 years ago

Incarus

I understand that this is wanted behaviour and the code should be kept easily maintainable.

All I was pointing out was that there is an overhead that might suggest the progress bar is not working as designed.

So waiting for a reply from Xwang1976 to see if what they see can be explained by the above description.

Alex

Report

Incarus

3 years ago

He could also do some testing out of the box if --progressbar is even working for him: http://techbase.kde.org/Development/Tutorials/Shell_Scripting_with_KDE_Dialogs#Progress_Dialogs

Might be a problem with DBus.

Report

webguy

3 years ago

A small thing, but the ClamScan.sh file still includes the line 'version=2.5.5', which is confusing for version 2.5.7, as the KDialog box title bar includes the version number
It also doesn't display the full result of the scan, just 'Result' with a dotted line underneath. The log for the day, and the individual scan logs have the full details though.

Report

Incarus

3 years ago

Thanks for your Feedback. I hope that I can fix this bugs in the next days but I can not longer maintain the script due to a couple of reasons.

Feel free to fork this project and to maintain your own script, I also changed the license to CC BY (now without SA).

Report

msx

3 years ago

Do I miss something!? xD

Report

tosta

4 years ago

pt:
Name[pt]=Verificar com ClamAV
wait="ClamAV está a verificar, por favor espere."
not_found="ClamAV não está instalado!"
scan_sentence="Verificando ficheiros: "

pt_BR:
Name[pt_BR]=Verificar com ClamAV
wait="ClamAV está verificando, por favor aguarde."
not_found="ClamAV não está instalado!"
scan_sentence="Verificando arquivos: "

Report

Incarus

4 years ago

Thanks! I will add it in the next release.

Report

yurix

4 years ago

Hi :) in "install.sh" script, add (in the third last line):

mkdir -p "$path2"


because some users may not have that folder (i was one of them).

BTW, thanks for your program. Bye :)

Report

Incarus

4 years ago

Hello and thank you the patch. I currently have no access to a linux-machine to test it but I'm gonna add it as soon as possible

Report

Incarus

4 years ago

I hope I fixed it now (2.5.6) and didn't break something with the file permissions (I had to do it in Windows)

Report

hilly53

5 years ago

Just thought I would let you know that the install went fine with one issue. I had to alter permissions for the script ClamScan.sh and everything works spot on. Prior to that all I got was the error that it could not locate the file ~/.kde/share/kde4/services/ServiceMenu/ClamScan/ClamScan.sh. Nicely done though thanks - very handy script.

..Phil

Report

Incarus

5 years ago

Thanks for the feedback.
Yeah, it didn't work for me either and I was really surprised, cause it did before.

Hope everything is fixed after that release ;)

Report

4 years ago

2013-6-18 (2.5.7)
- fixed permissions

2012-9-16 (2.5.6)
- fix: install-script: create path2 if it doesn't exist

2012-4-21 (2.5.5)
- support for linked directories
- support for empty directories
- unnecessary logfile gets deleted after scan, only result file remains
- fixed some if-conditions
- counts directories

2012-4-19 (2.5.4)
- fixed a wrong directory test (minor bug); now [ -d ] instead of [ -f ]
- did some testing on the mountable devices .desktop file, seems to work fine now

2012-4-19 (2.5.3)
- fixed a wrong set directory (~/.kde4/...) (that was for testing, I forgot to remove it)
- added spanish
- fixed this bug: gentooforum.de/artikel/17867/2/update-script.html when running ClamScan.sh without syntax

2012-2-23 (2.5.2)
- fixed recognition of empty directories which I broke in 2.3

2012-2-23 (2.5.1)
- Indonesian translation

2012-2-4 (2.5)
- using mkdir -p instead of if-conditions

(See Changelog file)

Don't forget to vote!

product-maker janet Nov 17 2015

product-maker brabus84 Mar 28 2014

product-maker msx Jul 26 2013

product-maker gustawho Jul 07 2013

product-maker Seniazi Jun 19 2013

product-maker electron222 Jun 10 2013

product-maker Omega9 Apr 10 2013

product-maker mixalns Sep 16 2012

product-maker som123xxx Sep 16 2012

product-maker RAIDENSUB Aug 15 2012

product-maker narya Apr 22 2012

product-maker roctheme Jan 27 2012

product-maker pru Jan 15 2012

product-maker pbuard Dec 19 2011

product-maker nikore90 Nov 11 2011

product-maker FraMari Jun 26 2011

product-maker gohanz Jun 26 2011

product-maker jorssoftware Feb 09 2011

product-maker svah4cky0 Jan 09 2011

product-maker deabru Jan 08 2011

product-maker sylgil88 Jan 08 2011

product-maker vitoubien Jan 08 2011

product-maker 6 6

File (click to download) Version Description Filetype Packagetype License Downloads Date Filesize OCS-Install DL
Details
version
2.5.7
updated Jun 18 2013
added Jan 08 2011
downloads today
0
page views today 0