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 .
Code:
#!/bin/bash
DIR=/home/cmccabe/Desktop/NGS/API
line_no=$(ls | awk -F . '{print $NF}' | sort | uniq -c | awk '{print $2,$1}') # count folder type and store as variable
echo >> $HOME/virus-scan.log"The folders detected are:
$line_no"
# Get rid of old log file
rm $HOME/virus-scan.log 2> /dev/null
while read FILE in $DIR;
do
# check file length is nonzero otherwise commands may be repeated
if [ -s $FILE ]; then
date > $HOME/virus-scan.log
clamscan -r $FILE >> $HOME/virus-scan.log
else "echo nothing detected by scan"
fi
done
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 OPENSOLARIS
vscand
vscand(1M) System Administration Commands vscand(1M)NAME
vscand - vscan service daemon
SYNOPSIS
/usr/lib/vscan/vscand
DESCRIPTION
vscand is the daemon that handles virus scan requests from file systems on file open and close operations. A file system may support
enabling and disabling of virus scanning on a per dataset basis, using that file system's administrative command, for example zfs(1M).
If the file state or scan policy (see vscanadm(1M) requires that a file be scanned, vscand communicates with external third-party virus
scanners (scan engines) using the Internet Content Adaptation Protocol (ICAP, RFC 3507) to have the file scanned.
A file is submitted to a scan engine if it has been modified since it was last scanned, or if it has not been scanned with the latest scan
engine configuration (Virus definitions). The file's modified attribute and scanstamp attribute are used to store this information. Once
the file is scanned, the modified attribute is cleared and the scanstamp attribute is updated.
If the file is found to contain a virus, the virus is logged in syslogd(1M), an audit record is written, and the file is quarantined (by
setting its quarantine attribute). Once a file is quarantined, attempts to read, execute or rename the file will be denied by the file sys-
tem. The syslogd(1M) entry and the audit record specify the name of the infected file and the violations detected in the file. Each viola-
tion is specified as "ID - threat description", where ID and threat description are defined in the X-Infection-Found-Header in ICAP RFC
3507; Extensions.
By default, vscand connects to scan engines on port 1344. The port and other service configuration parameters can be configured using
vscanadm(1M).
The vscan service is disabled by default, and can be enabled using svcadm(1M).
EXIT STATUS
The following exit values are returned:
0 Daemon started successfully.
non-zero Daemon failed to start.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWvscanu |
+-----------------------------+-----------------------------+
|Interface Stability |Uncommitted |
+-----------------------------+-----------------------------+
SEE ALSO ps(1), svcs(1), logadm(1M), svcadm(1M), syslogd(1M), vscandadm(1M), zfs(1M), attributes(5), smf(5)NOTES
If a file is accessed using a protocol which does not invoke the file system open and close operations, for example NFSv3, virus scanning
is not initiated on the file.
File content is transferred to the scan engines as cleartext data.
Administrative actions for the vscan service, such as enabling, disabling, or requesting a restart, can be performed using svcadm(1M). The
vscan service status can be queried using the svcs(1) command.
The vscan service is managed by the service management facility, smf(5), under the service identifier:
svc:/system/filesystem/vscan
SunOS 5.11 6 Nov 2007 vscand(1M)