On Mon, 24 Apr 2006 13:16:57 +0200
Roman ZARAGOCI wrote:

> >> For example, I would want to scan only new files added to homes 
> >> directories or by checking the modification date of files.
> >> Maybe someone has already made this sort of script ?
> >
> > If you run something like:
> >
> >    find /home -mtime -2 -type f -print0 | xargs -0 clamdscan
> I've got a specific problem with my script, let me explain what it
> does :
> 
> 1) # First, the script build a text file named "file1" containing all
> modified files last day
> find /home -mtime -1 -type f > /tmp/file1
> 
> 2) # Then, the command grep excludes all lines containing "mail" (to
> not scan mail files - too long and already scan by another soft)
> grep -v mail /tmp/file1 > /tmp/file2
> 
> 3) # Because clamdscan needs a single line as parameter to specify
> files/repertories to scan, I apply this :
> while read line; do echo -e "\"$line\" \c"; done < file2
> 
> So, the file named "file2" contains a single line with this format :
> "/home/first file" "/home/second file" ...
> I add a double-quote to scan files with spaces.
> 
> But when I do :
> while read line; do echo -e "\"$line\" \c"; done < file2 | xargs -0
> clamdscan
> clamdscan replies :
> 
> [...] "/home/tbigo/some file.exe" "/home/updvir/update.ini"
> "/home/updvir/dat-4746.zip" : File name too long


 Your scripting skills are somewhat flaky :) This is not an exemplary
method/script, but should give you a general idea, keeping the general
context of your script.

#/bin/sh

find /home -mtime -1 -type f > /tmp/file1;
filelist=`grep -v mail /tmp/file1`;

{
 for x in ${filelist}
  do
    clamdscan ${x}
 done
}

#End of file

 The above has no particular semantics or such, but gives a basis to
work from.


Matt

p.s: Before anyone starts pointing out problems with the above quick
     script, it was not meant to be a scripting reference, just a vague
     guideline/concept :)
_______________________________________________
http://lurker.clamav.net/list/clamav-users.html

Reply via email to