[ale] shell scripting baby questions...

Byron A Jeff byron at cc.gatech.edu
Fri Feb 20 11:28:21 EST 2004


On Fri, Feb 20, 2004 at 11:14:31AM -0500, Nathan J. Underwood wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Ok, I'm gonna step out on a limb here.  Do you need the quotation marks
> around the 0 in this case?

Nope.

>  Also, should the variable name have quotes around it?

Maybe. Depends on if it could be blank or not. Since it's the output
from wc -l, I would say not.

BAJ
> 
> ~  if [ "$infectionsDetected" eq 0 ]
> ~  then
> ~    rm -f $logPath/$infectedLogName
> ~  fi
> 
> nathan
> 
> Keith Morris - IQ wrote:
> 
> | let me start out by saying thanks for all the help you all have been to
> | me in the past (both directly and indirectly).  thanks.
> |
> | I'm starting out will shell scripting (so new I'm still wet behind the
> | ears) and am writing my first really useful script.  I am using
> | BitDefender free command line virus scanner to scan for virii and
> | working on a script to automate the process to put into a cron job.  the
> | basic functionality is working except for the checking to see if any
> | virii were detected.  I'm not clear on the string/binary operators in
> | the if statement and can't get it to work out correctly.
> |
> | If someone has time and would be willing to look at this script and 1.
> | help me get the virii log detection working, and 2. possibly show me a
> | couple of hints to make this more efficient.  Thanks.
> |
> | --- start script ---
> |
> | #!/bin/bash
> | #
> | # Script to run BitDefender nightly and report
> | # the full scan as well as create an infected
> | # file report
> | #
> |
> | # file and path variables
> | reportTime=`date +%y%m%d_%H%M%S`;
> | logName="scan_$reportTime.log";
> | infectedLogName="infected_$reportTime.log";
> | logPath="/home/samba/production/vlogs";
> | dirToScan="/home/samba/production";
> |
> | # update virus defs
> | /opt/bdc/bdc --update;
> |
> | # run virus scan with logging
> | /opt/bdc/bdc --arc --disinfect --log=$logPath/$logName $dirToScan;
> |
> | # list all found infected files into an infected log
> | cat $logPath/$logName | grep infected: > $logPath/$infectedLogName;
> |
> | # find out if there were any found infections
> | infectionsDetected=`cat $logPath/$infectedLogName | wc -l`;
> |
> | # if no virii were detected, deleted infected log file.
> | # *!!! this ain't workin' !!!*
> |
> |  if [ $infectionsDetected eq "0" ]
> |  then
> |    rm -f $logPath/$infectedLogName
> |  fi
> |
> | # tar and gzip the scan logfile and remove the uncompressed log
> | tar -czf $logPath/$LogName.tgz $logPath/$infectedLogName;
> | rm -f $logPath/$logName;
> |
> | --- end script ---
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (MingW32)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> 
> iD8DBQFANjJnl9gX8cEx2b4RAgnCAJ9RQi0i2y8OMqQlB0M2v3GINWH/gACfWIY7
> rEoabvJPjZoiTv6By1cwA0E=
> =CN2N
> -----END PGP SIGNATURE-----
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale



More information about the Ale mailing list