Create automated scan of specific directory using bash
I am trying to use bash to automate the scan of a specific directory using clamav. Having this in place is a network requirement. The below is an attempt to:
1. count the extensions (.txt, .jpeg) in a directory and write them to a virus-scan.log (section in bold)
2. scan each folder in the dir and log the results of the scan by date. (section in italics)
Each folder in the directory is scanned and the results of each day the scan is run is logged to /HOME/virus-scan.log by date.
Thank you .
Last edited by cmccabe; 01-06-2017 at 12:10 PM..
Reason: fixed format
hi everyone,
I just began to be interested about the bash access.
I buy a time ago a Raspberry pi, I installed raspbmc and now I would like build a bash to copy everyday all new files inside my server directly on the hard drive in my Pi.
So my HDD is directly plug on my pi with usb connect,... (4 Replies)
Hello Team,
I have Solaris 10 u6
I have a user test1 using bash that belong to the group staff.
I would like to restrict this user to navigate only in his home directory and his subfolders but not not move out to other directories.
How can I do it ?
Thanks in advance (1 Reply)
I have a bash that downloads a list and if that list has data in it then a new main directory is created (with the date) with several subdirectories (example1, example2, example3). My question is in that list there are portion of specific file types (.vcf.gz) - identifier towards the end that have... (0 Replies)
I am using bash to prompt a user for a choice using: where a "y" response opens a menu with available panels that can be used.
while true; do
read -p "Do you want to get coverage of a specific panel?" yn
case $yn in
* ) menu; break;;
* ) exit;;
* ) echo... (6 Replies)
The below bash is trying to list the folders in a specific directory. It seems close but adds the path to the filename, which basename could strip off I think, but not sure why it writes the text file created? This list of folders in the directory will be used later, but needs to only be the... (5 Replies)
Hello, how in bash i can get directory loop, but only choose those folders with specific word in it, so it will only echo those with specific word
#!/bin/bash
for filename in /home/test/*
do
if ; then
echo $filename;
fithx! (4 Replies)
In the bash below I am trying to create sub-directories inside a directory from files with specific .bam extensions. There may be more then one $RDIR ing the directory and the .bam file(s) are trimmed (removing the extension and IonCode_0000_) and the result is the folder name that is saved in... (2 Replies)
In the below I am trying to create a parent directory using the R_2019 line from f1 if what above it is not empty.
I then create sub-directories under each parent if there is a match between $2 of f1 and $2. Inside each sub-folder the matching paths in $3 and $4 in f2are printed. If there is no... (2 Replies)
In the below bash I am trying to ensure that all folders (represented by $folders) in a given directory are created. In the file f1 the trimmed folder will be there somewhere (will be multiple trimmed folders).
When that trimmed folder is found (represented by $S5) the the contents of $2 printed... (19 Replies)
Discussion started by: cmccabe
19 Replies
LEARN ABOUT DEBIAN
file::scan
Scan(3pm) User Contributed Perl Documentation Scan(3pm)NAME
File::Scan - Perl extension for Scanning files for Viruses
SYNOPSIS
use File::Scan;
$fs = File::Scan->new([, OPTION ...]);
$fs->set_callback(
sub {
my $filename = shift;
my $bytes = shift;
...
return("Callback Value");
}
);
$fs->scan([FILE]);
if(my $e = $fs->error) { print "$e
"; }
if(my $c = $fs->skipped) { print "file skipped ($c)
"; }
if($fs->suspicious) { print "suspicious file
"; }
if(my $res = $fs->callback) { print "$res
"; }
DESCRIPTION
This module is designed to allows users to scan files for known viruses. The purpose is to provide a perl module to make plataform
independent virus scanners.
METHODS
new([, OPTION ...])
This method create a new File::Scan object. The following keys are available:
callback => 'subroutine reference'
if the item is set then use a callback subroutine reference to provide extra information and functionalities. The callback
subroutine have two arguments: filename and first 1024 bytes read from the file. This only work for binary files.
extension => 'string'
add the specified extension to the infected file
move => 'directory'
move the infected file to the specified directory
copy => 'directory'
copy the infected file to the specified directory
mkdir => octal_number
if the value is set to octal number then make the specified directories (example: mkdir => 0755).
delete => 0 or 1
if the value is set to 1 delete the infected file
max_txt_size => 'size in kbytes'
scan only the text file if the file size is less then max_txt_size. The default value is 5120 kbytes. Set to 0 for no limit.
max_bin_size => 'size in kbytes'
scan only the binary file if the file size is less then max_bin_size. The default value is 10240 kbytes. Set to 0 for no limit.
scan([FILE])
This method scan a file for viruses and return the name of virus if a virus is found.
set_callback([SUBREF])
This method is another way to install a callback subroutine reference. Take a look in callback kay.
skipped()
This method return a code number if the file was skipped and 0 if not. The following skipped codes are available:
0 file not skipped
1 file is not vulnerable
2 file has zero size
3 the size of file is small
4 the text file size is greater that the 'max_txt_size' argument
5 the binary file size is greater that the 'max_bin_size' argument
suspicious()
This method return 1 if the file is suspicious and 0 if not.
callback()
This method return the result from the callback subroutine.
error()
This method return a error message if a error happens.
AUTHOR
Henrique Dias <hdias@aesbuc.pt>
CREDITS
Thanks to Rui de Castro, Sergio Castro, Ricardo Oliveira, Antonio Campelo, Branca Silveira, Helena Gomes and Anita Afonso for the help.
Thanks to Fernando Martins for the personal collection of viruses.
SEE ALSO perl(1).
perl v5.10.0 2009-07-19 Scan(3pm)