#!/bin/bash # Author: Josh Friberg-Wyckoff # Filename: findexe.sh # Date: March 9, 2004 # Revised: November 23, 2004 # Version 2.0 # Purpose: Used to find executable files in students # home directories. Even if they are renamed. # Limitations: Currently the script does not have the # ability to look inside compressed files. I was thinking # that some day I would add this to the script but you # could just grep for compressed. # Special thanks to Paul Massey and Joe Cicero. # Without them I would just be another linux noobie. DAYofWEEK=`date +%a` # Used to set which grade level will be scanned at night. # Takes to long to scan all the students in one night case $DAYofWEEK in "Sun") GRADYEAR="NO";; "Mon") GRADYEAR="2005";; "Tue") GRADYEAR="2006";; "Wed") GRADYEAR="2007";; "Thu") GRADYEAR="2008";; "Fri") GRADYEAR="2009";; "Sat") GRADYEAR="2010";; esac if [ $GRADYEAR != "NO" ]; then THEPATH=netware/students/$GRADYEAR NAMEPART2=`date +-run-%Y-%m-%d` FILENAME=Exe_Violators_$GRADYEAR$NAMEPART2.txt #mounting the netware file system ncpmount -S FS2 -A fs2.somedomain.com -U username.ou.o -P password -C -V VOL1 netware # Time Stamping when the script started date > $FILENAME # Doing all the dirty work on this one line. # The find statement finds all files specified in the path. # The Sed statement wraps quotes around the path incase there are spaces. # The xargs file command is what tells you what type of file it is. # The cut command is just for formatting of the file. It can be removed safely. find $THEPATH -type f | sed -e 's/^/\"/' -e 's/$/\"/' | xargs file -z | grep executable | cut -d ":" -f1 >> $FILENAME # Time Stamping when the script ended date >> $FILENAME # changing the log file to a dos file format so we can read it in notepad unix2dos $FILENAME # copying the file to the I.T. shared directory cp $FILENAME netware/IS_Share/exe_scan # unmounting the netware volume ncpumount netware fi